Re: Sorting array
- From: Robert Kern <robert.kern@xxxxxxxxx>
- Date: Fri, 30 Nov 2007 14:55:08 -0600
Tartifola wrote:
Hi,
I'm working with numerical array and I'm a little lost on a particular
sorting of one of them. In particular I have an array like
a = array([[8,4,1],[2,0,9]])
and I need to sort it using only the first column as reference but
keeping the lines together so to obtain
array([[2, 0, 9],
[8, 4, 1]])
In [1]: from numpy import *
In [2]: a = array([[8,4,1],[2,0,9]])
In [3]: i = argsort(a[:,0])
In [4]: a[i]
Out[4]:
array([[2, 0, 9],
[8, 4, 1]])
numpy questions are best asked on the numpy-discussion mailing list since
everyone there automatically knows that you are talking about numpy arrays and
not just misnaming lists. ;-)
http://www.scipy.org/Mailing_Lists
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
.
- References:
- Sorting array
- From: Tartifola
- Sorting array
- Prev by Date: Re: Sorting array
- Next by Date: issue with cookielib.LWPCookieJar
- Previous by thread: Re: Sorting array
- Next by thread: Unicode string formating
- Index(es):
Relevant Pages
|