sorting strings by size
Oleg Broytmann
phd at phd.pp.ru
Thu Aug 9 09:08:26 EDT 2001
On Thu, 9 Aug 2001, Mark Robinson wrote:
> Can anyone thing of a more eligant way of doing this? I am trying to
> extract the keys of my dict and sort them according to size, but this
> currently seems kinda crude
>
> temp = [(len(x), x) for x in motifs.keys()]
> temp.sort()
> temp.reverse()
> motiflist = [x[1] for x in temp]
According to Sorting HOWTO
http://py-howto.sourceforge.net/sorting/sorting.html
you are doing fine, nothing crude here!
Oleg.
----
Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru
Programmers don't die, they just GOSUB without RETURN.
More information about the Python-list
mailing list