Steven D'Aprano <[EMAIL PROTECTED]> writes:
> I recently needed to write a function to generate a rank table from a
> list. That is, a list of ranks, where the rank of an item is the position
> it would be in if the list were sorted:
> 
> alist = list('defabc')
> ranks = [3, 4, 5, 0, 1, 2]

fst = operator.itemgetter(0)   # these should be builtins...
snd = operator.itemgetter(1)

ranks=map(fst, sorted(enumerate(alist), key=snd))
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to