
July 23, 2010
8:49 a.m.
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 ) etc... HTH, Jon