Sorting a dictionary

Alex alex at somewhere.round.here
Wed Mar 15 13:07:37 EST 2000


> The Library Reference says that for mydict.keys(), mydict.values() and
> mydict.items(), "Keys and values are listed in random order".  The
> above solution only works if the _same_ random order is used for both
> keys and values.  It is very reasonable to imagine the implementation
> is such that the random order is the same, but the specification does not
> promise it.  So, even if elegant, the solution above might be wrong from
> a theoretical standpoint.
> 
> Could the documentation of Python be modified to clarify this point,
> in one way or another?

You're right, I had read on the newsgroup that the same order is
guaranteed, but hadn't seen it anywhere more official.

I should read the Library Reference at some point.

Alex.



More information about the Python-list mailing list