Sorted dictionary

Steven D'Aprano steven at REMOVE.THIS.cybersource.com.au
Wed Jan 20 20:50:58 EST 2010


On Thu, 21 Jan 2010 02:02:02 +0100, Jan Kaliszewski wrote:

> Hello,
> 
> Inspired by some my needs as well as some discussions in the net, I've
> implemented a sorted dictionary (i.e. a dict that returns keys, values
> and items always sorted by keys):
> 
> http://code.activestate.com/recipes/576998/


What's the advantage of that over sorting the keys as needed?


E.g.

for key in sorted(dict):
    print key


works.




-- 
Steven



More information about the Python-list mailing list