Efficient Rank Ordering of Nested Lists

pablo.mitchell at gmail.com pablo.mitchell at gmail.com
Mon Aug 6 00:29:00 CEST 2007

On Aug 4, 7:29 pm, al... at mac.com (Alex Martelli) wrote:
> Cousin Stanley <cousinstan... at gmail.com> wrote:
>    ...
> >       for i , item in reversed( enumerate( sorted( single_list ) ) ) :
>    ...
> > TypeError: argument to reversed() must be a sequence
> Oops, right.  Well then,
>     aux_seq = list(enumerate(sorted(single_list)))
>     for i, item in reversed(aux_seq): ...
> or the like.
> Alex

The particular embedded list I have been tinkering with is 43 x 3884
and the dictionary approach (as you can probably guess) is a big
improvement over the linear one.  It also has the added benefit of
being compatible with Python24.  If I'm not mistaken the binary
approach suggested by Neil requires Python25.  Since in some
situations I don't have control over the version available I will go
with a variant of the dictionary recipe.

More information about the Python-list mailing list