NumPy argsort question

Ivan Lima ivan at
Fri Apr 23 20:24:08 CEST 2004


  I have two 2-dimensional arrays A and B. I want to sort A along its
  columns (axis=1) and then sort B along its columns in the same order
  that A was sorted. 

  I tried:

        sorted_A = sort(A,1)
        sorted_B = take(B, argsort(A,1), 1)

  but my last statement returns an array with an extra dimension. If A
  is a 2x3 matrix I get a 2x2x3 matrix. What am I missing?

  Thanks a lot,
Ivan Lima - idl764 at yahoo dot com

More information about the Python-list mailing list