[Numpy-discussion] Arrays of Python Values

Jon Wright wright@esrf...
Fri Jul 23 03:49:05 CDT 2010

Ian Mallett wrote:

> self.patches.sort( lambda 
> x,y:cmp(x.residual_radiance,y.residual_radiance), reverse=True )
> more, but I couldn't figure out how I'd handle the different attributes 
> (or specifically, how to keep them together during a sort).

I'm not sure you gain much using numpy to sort python objects. In any 
case, how about:

r = [ x.residual_radiance for x in self.patches ]
ordered_indices = numpy.argsort(r)
ordered_patches = numpy.take( self.patches, indices )
ordered_other_thing = numpy.take( other_thing, indices )




More information about the NumPy-Discussion mailing list