Is numeric keys of Python's dictionary automatically sorted?

Paul Rubin http
Thu Mar 8 05:46:40 EST 2007


"John" <rds1226 at sh163.net> writes:
> I am coding a radix sort in python and I think that Python's dictionary may 
> be a choice for bucket.

Why are you coding a radix sort? 

> The only problem is that dictionary is a mapping without order. But
> I just found that if the keys are numeric, the keys themselves are
> ordered in the dictionary.

Just an accident, dicts are implemented using hashing, and small
integers hash to themselves.



More information about the Python-list mailing list