[Newbie] How to output dictionary sorted on content (not keys)

Achim Domma achim.domma at syynx.de
Thu Jul 4 15:34:07 EDT 2002


"Eric Brunel" <eric.brunel at pragmadev.com> wrote in message
news:ag1fj0$inr$1 at wanadoo.fr...
> I don't which one of these two or Achim's one is the most efficient.

I also don't know, but you can make it in one line:

for count,name in dict([ (count,name) for name,count in
myDict.items() ]).items(): print count,name

wether this is good code or not is another question ... ;-)

Achim






More information about the Python-list mailing list