sorting values in dictionary in python

s = {1: 1, 7: 2, 4: 2, 3: 1, 8: 1}
k = dict(sorted(s.items(),key=lambda x:x[0],reverse = True))
print(k)

Here is what the above code is Doing:
1. We have a dictionary s which contains the elements and their frequencies.
2. We sort the dictionary s in reverse order according to the keys.
3. We store the sorted dictionary in a new dictionary k.
4. We print the dictionary k.