Source Code:
(back to article)
d = {'apple': 1, 'banana': 3, 'orange': 2} sorted_d = dict(sorted(d.items(), key=lambda x: x[1], reverse=True)) print(sorted_d) # Output: {'banana': 3, 'orange': 2, 'apple': 1}
Result:
Report an issue