[Numpy-discussion] Sort , Complex array

Gerard Vermeulen gvermeul at labs.polycnrs-gre.fr
Mon Nov 26 02:48:02 CST 2001


On Monday 26 November 2001 11:53, Nils Wagner wrote:
> Hi,
>
> How can I sort an array of complex eigenvalues with respect to the
> imaginary part
> (in ascending order) in Numpy ?
> All eigenvalues appear in complex cunjugate pairs.
>
> Nils
>

I have solved that like this:
>>> from Numeric import *
>>> a = array([3+3j, 1+1j, 2+2j])
>>> b = a.imag
>>> print take(a, argsort(b))
[ 1.+1.j  2.+2.j  3.+3.j]
>>>

Best regards -- Gerard





More information about the Numpy-discussion mailing list