Write a Python program to sort (Descending) a dictionary by value.


Topic: Write a Python program to sort (Descending) a dictionary by value.

Solution

d = {1: 2, 3: 4, 4: 3, 2: 1, 0: 0}
print({k :v for k,v in sorted(d.items(),key = lambda x : x[1],reverse = True)})



List all Python Programs