You yourself cannot order a dictation, but you can convert it to a list of tuples (key, value), and you can sort them.
To do this, use the .items () method. For example,
>>> {'a': 1, 'b': 2}
{'a': 1, 'b': 2}
>>> {'a': 1, 'b': 2}.items()
[('a', 1), ('b', 2)]
- . cmp , , . , , :
sorted(somedict.items(), key=lambda x: {'carrot': 2, 'banana': 1, 'apple':3}[x[0]])
dict, , , dict.