[Numpy-discussion] sort

Gael Varoquaux gael.varoquaux@normalesup....
Thu Apr 17 05:23:38 CDT 2008

On Thu, Apr 17, 2008 at 03:18:45AM -0700, wilson wrote:
> i have a 1 dimensional array of floats that i want to sort in
> descending order.i did as follows

> from numpy import tolist,array,sort
> y=array([......]) #may be 1000 items
> z=sort(y)
> l=z.tolist()
> l.reverse()
> rl=array(l)

> now rl is a 1 dim array sorted in descending order.
> but i am looking for a better,compact way to do this.can someone help?

Not tested, but something like
y = array([......]) #may be 1000 items
y = y[::-1]


More information about the Numpy-discussion mailing list