Iterate a dictionary in a sorted fashion
for theSortedKey in sorted(theKeyValues):
theValue = theKeyValues[theSortedKey]
...