list conversion question

Raymond Hettinger vze4rx4y at verizon.net
Sun Sep 5 08:54:37 CEST 2004


[Peter Otten]
> > Yet another option, not benchmarked, perhaps clearer:
>
> >>>>hist = [0, 1, 0, 5, 43]
> >>>>indices = range(len(hist))
> >>>>indices.sort(key=hist.__getitem__)
> >>>>indices
> >
> > [0, 2, 1, 3, 4]

[Andrew Dalke]
> Looks the fastest to me.  Here's my results, with
> the benchmark below.
 . . .

These results are good.  Consider posting them in the ASPN Cookbook so they
won't get lost.


Raymond Hettinger





More information about the Python-list mailing list