Q:

Can internal dictionary order change?

exampleDict = {'a':1, 'b':2, 'c':3, 'd':4}

The above dictionary initially iterated through in this order:
b=2
d=4
a=1
c=3

Then, I moved around a ton of files in my code, and now it iterates through in this order:
d=4
a=1
c=3
b=2

I know that the order is internally stored as a hashmap, but what would cause that internal order to change?
Edit: I don't need to preserve order so I will stick with using a dict. I am just wondering why it happened. I thought order wasn't guaranteed, but once it has its arbitrary internal order, it sticks with it for future iterations.

A:

Dict don't have a fixed order, from documentation

CPython implementation detail: 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.

If you really need to keep it ordered, there is an object called OrderedDict :
from collections import OrderedDict
exampleDict = OrderedDict({'a':1, 'b':2, 'c':3, 'd':4})

see also OrderedDict documentation here

