[Numpy-discussion] indexing to sort with argsort(..., axis=1)
Mon Apr 12 21:41:14 CDT 2010
I want to sort a 2d array along one dimension, with the indices returned by
argsort, but the subsequent indexing syntax to get the sorted array is not
The following works, but I wonder if there is a simpler way:
a = np.random.random(size=(5,3))
s = np.argsort(a, axis=1)
sorted = a[:,s][np.eye(5,5, dtype=bool)] # it looks like this line could be
What's the correct, concise way to do this?
Post-doctoral research fellow
Neurobiology, University of Pittsburgh
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion