[Numpy-discussion] argsort

Mads Ipsen madsipsen@gmail....
Tue Jan 15 05:50:20 CST 2013


Hi,

I simply can't understand this. I'm trying to use argsort to produce 
indices that can be used to sort an array:

   from numpy import *

   indices = array([[4,3],[1,12],[23,7],[11,6],[8,9]])
   args = argsort(indices, axis=0)
   print indices[args]

gives:

[[[ 1 12]
   [ 4  3]]

  [[ 4  3]
   [11  6]]

  [[ 8  9]
   [23  7]]

  [[11  6]
   [ 8  9]]

  [[23  7]
   [ 1 12]]]

I thought this should produce a sorted version of the indices array.

Any help is appreciated.

Best regards,

Mads

-- 
+-----------------------------------------------------+
| Mads Ipsen                                          |
+----------------------+------------------------------+
| Gåsebæksvej 7, 4. tv |                              |
| DK-2500 Valby        | phone:          +45-29716388 |
| Denmark              | email:  mads.ipsen@gmail.com |
+----------------------+------------------------------+

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20130115/e8894f40/attachment.html 


More information about the NumPy-Discussion mailing list