Is numeric keys of Python's dictionary automatically sorted?

John rds1226 at sh163.net
Wed Mar 7 15:49:35 EST 2007


Then is there anyway to sort the numeric keys and avoid future implemetation 
confusion?


"Ant" <antroy at gmail.com> wrote in message 
news:1173300100.810023.223130 at t69g2000cwt.googlegroups.com...
> On Mar 7, 8:18 pm, "John" <rds1... at sh163.net> wrote:
> ...
>> However, I am not sure whether it is always like this. Can anybody 
>> confirm
>> my finding?
>
>>From the standard library docs:
>
> "Keys and values are listed in an arbitrary order which is non-random,
> varies across Python implementations, and depends on the dictionary's
> history of insertions and deletions."
>
> i.e. the behaviour you have discovered is an implementation detail,
> and could change in future versions.
> 





More information about the Python-list mailing list