1s = {1: 1, 7: 2, 4: 2, 3: 1, 8: 1}
2k = dict(sorted(s.items(),key=lambda x:x[0],reverse = True))
3print(k)
1#instead of using python inbuilt function we can it compute directly.
2#here iam sorting the values in descending order..
3d = {1: 1, 7: 2, 4: 2, 3: 1, 8: 1}
4s=[]
5for i in d.items():
6 s.append(i)
7for i in range(0,len(s)):
8 for j in range(i+1,len(s)):
9 if s[i][1]<s[j][1]:
10 s[i],s[j]=s[j],s[i]
11print(dict(s))