list1 = { 'aa':4, 'ab':3, 'wr':7, 'de':6 } print({k: v for k, v in sorted(list1.items(), key=lambda item: item[1],reverse=True)})
I've used the list comprehension to sort by the values of the dictionary
2.1m questions
2.1m answers
60 comments
57.0k users