print dictionary python in order of sorted by key code example Example: sort dictionary by key sortedDictionary = sorted(mydictionary.keys())