May I know why this is happening?
It is because of the way dicts are organized internally.
In short, this works via a hash-table which puts the keys into buckets according to their hash() value.
If I use dict.keys() to extract the keys from a dictionary and iterate it in an order that I suppose it to be, will that cause dismatch problem?
Depending on how you do it.
k = list(d.keys())
k.sort()
for i in k: print i, d[i]
should exactly work how you want it to work.