[Tutor] Elegant argument index sort

Kent Johnson kent37 at tds.net
Thu Nov 8 14:55:56 CET 2007


Dinesh B Vadhia wrote:
> I'm sorting a 1-d (NumPy) matrix array (a) and wanting the index results 
> (b).  This is what I have:
>  
> b = a.argsort(0)
> b = b+1
>  
> The one (1) is added to b so that there isn't a zero index element.  Is 
> there a more elegant way to do this?

b = a.argsort(0) + 1

?

Kent


More information about the Tutor mailing list