[Numpy-discussion] is there a sortrows
Pierre GM
pgmdevlist at gmail.com
Sun Dec 21 23:10:26 EST 2008
On Dec 21, 2008, at 10:19 PM, josef.pktd at gmail.com wrote:
>
>> From the examples that I tried out np.sort, sorts each column
> separately (with axis = 0). If the elements of a row is supposed to
> stay together, then np.sort doesn't work
Well, if the elements are supposed to stay together, why wouldn't you
tie them first, sort, and then untie them ?
>>> np.sort(a.view([('',int),('',int)]),0).view(int)
The first view transforms your 2D array into a 1D array of tuples, the
second one retransforms the 1D array to 2D.
Not sure it's better than your lexsort, haven't timed it.
More information about the NumPy-Discussion
mailing list