I'd map the values to their index in a dictionary, then sort the list,
and from the sorted list fetch all the indexes from the dictionary.
Something like :

>>> a = [2,3,1,4,5]
>>> b = list(a)
>>> b.sort()
>>> b
[1, 2, 3, 4, 5]
>>> indexDict = dict([ (value, index) for index, value in
enumerate(a)])
>>> [indexDict[entry] for entry in b]
[2, 0, 1, 3, 4]

HTH

The code above uses enumerate, to shortcut getting the index. There may
be other shortcuts possible.

Regards,

Fuzzy
http://www.voidspace.org.uk/python

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to