sorting a dictionary

Paul Rubin phr-n2003b at NOSPAMnightsong.com
Tue Feb 4 05:31:52 EST 2003


Andrew Bennetts <andrew-pythonlist at puzzling.org> writes:
> Sure you can... what's wrong with the solution I posted earlier:
> 
>     max([(x[1], x[0]) for x in d.items()])[1]
> 
> ?
> 
> [Besides being a gratuitous one-liner <wink>]

That uses linear extra storage vs. Alex's which uses constant space.





More information about the Python-list mailing list