python sort a dictionary on keys code example Example: sort dictionary by key sortedDictionary = sorted(mydictionary.keys())