[Numpy-discussion] sorting ndarray

Eric Firing efiring@hawaii....
Fri Apr 4 01:09:39 CDT 2008


harryos wrote:
> i have a 1 dim numpy array
> D=array( [[ 3. ,  2. ,  1.  , 4. ,  5.  , 1.5,  2.2]] )

This is a 2-D array, not a 1-D array.


> i need to get this sorted in descending order and then access the
> elements .
> D.sort() will make D as [[ 1.   1.5  2.   2.2  3.   4.   5. ]]
> how will i reverse it?

In [8]:D[:,::-1]
Out[8]:array([[ 5. ,  4. ,  3. ,  2.2,  2. ,  1.5,  1. ]])



> or is there a simpler way?
> harry
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion



More information about the Numpy-discussion mailing list