I'm making dictionary:
d = {"server":"mpilgrim", "database":"master"}
d['mynewkey'] = 'mynewvalue'
But when I display it I saw that this dict is reversed.
print(d)
{'mynewkey': 'mynewvalue', 'database': 'master', 'server': 'mpilgrim'}
How to reverse it back?
Or if it is true that dictionary is not sortable what I must to use to have collection where the order of that informations matters?
解决方案
Dictionary are unordered (the order is deterministic, but depends on a handful of factors you don't even think of and shouldn't care about - hash of the keys, order of insertion, collisions, etc). In Python 2.7+, use collections.OrderedDict. If you must use an older version, there are various implementations google can point you to.