>>> a = numpy.array([[1,2,6], [2,2,8], [2,1,7],[1,1,5]])
>>> a
array([[1, 2, 6],
[2, 2, 8],
[2, 1, 7],
[1, 1, 5]])
>>> indices = numpy.lexsort(a.T)
>>> a.T.take(indices,axis=-1).T
array([[1, 1, 5],
[1, 2, 6],
[2, 1, 7],
[2, 2, 8]])
The above does what I want, equivalent to sorting on column A then
column B in Excel, but al the transposes are ungainly. I've stared at it a while
but can't come up with a more elegant solution. Any ideas?
cheers Eleanor
_______________________________________________
Numpy-discussion mailing list
[email protected]
http://projects.scipy.org/mailman/listinfo/numpy-discussion