Source Code:
(back to article)
original_dict = {'c': 3, 'a': 1, 'b': 2} # Sort the keys of the dictionary sorted_keys = sorted(original_dict.keys()) # Iterate over the keys in sorted order for key in sorted_keys: print(key, original_dict[key])
Result:
Report an issue