1>>> a = {0:'000000',1:'11111',3:'333333',4:'444444'}
2>>> a.keys()
3[0, 1, 3, 4]
4>>> sorted(a.keys())
5[0, 1, 3, 4]
6>>> reversed(sorted(a.keys()))
7<listreverseiterator object at 0x02B0DB70>
8>>> list(reversed(sorted(a.keys())))
9[4, 3, 1, 0]
1# Python3 using reversed() + items()
2test_dict = {'Hello' : 4, 'to' : 2, 'you' : 5}
3
4rev_dict = dict(reversed(list(test_dict.items()))) # Reversing the dictionary
5
6print("The original dictionary : " + str(test_dict))
7print("The reversed order dictionary : " + str(rev_dict))
8
9# Output:
10"The original dictionary : {'Hello': 4, 'to': 2, 'you': 5}"
11"The reversed order dictionary : {'you': 5, 'to': 2, 'Hello': 4}"