On Apr 29, 5:33 pm, Paul Rubin <http://[EMAIL PROTECTED]> wrote: > 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))
This is what the OP calls the index table, not the ranks table (both are the same for the example above, but that's an unfortunate coincidence...) -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list