python : how to disable auto sort when creating dictionary
Items stored in a dictionary do not have any inherent order. The order they are printed out is entirely down to the hash values for each of the keys and the other items in the dictionary.
It is not sorting. dict
is not ordered at all, so you cannot influence the key order in any way. There is collections.OrderedDict
in 2.7 and 3.1+, there is also standalone module for 2.4-2.6.