Dictionary in python is not ordered , the order in which you are receiving the keys is basically dependent on the python implementation. Your code should not depend on it.
From documentation -
It is best to think of a dictionary as an unordered set of key: value pairs, with the requirement that the keys are unique (within one dictionary)
If order is important for your program, use collections.OrderedDict . Example -
>>> from collections import OrderedDict
>>> d = OrderedDict([('a','b'),('x','x'),('2','2')])
>>> for c in d:
... d[c]
...
'b'
'x'
'2'