[Matrix-SIG] Fast sorting many lists together...?

Tim Hochberg tim.hochberg@ieee.org
Fri, 15 Sep 2000 11:08:53 -0600


> I need to sort about 50 lists (each about 500 elements) together, using
few
> of them as keys.  That is, sort the key lists first; look at which indexes
> have changed; then, shuffle the rest of list to reflect this new order.
>
> Does anyone know a fast fast routine for doing this?

You probably have to give more details about the way you are using multiple
lists as keys in order to get a complete response. However, if you have
created a single list of keys, you can do something like.

args = Numeric.argsort(keys)
keys = Numeric.take(keys, args) # Sort the keys
list1 = Numeric.take(list1, args) # Sort list 1
list2 = Numeric.take(list2, args) # Sort list 2
#....

-tim