Answers for "python dictionary print key value ascending order"

0

python dictionary print key value ascending order

word_dict = { 'this': 11, 'at': 9, 'here': 5, 'why': 12, 'is': 2 }
# Sort Dictionary by value in descending order using lambda function
sorted_dict = dict( sorted(word_dict.items(),
                           key=lambda item: item[1],
                           reverse=True))
print('Sorted Dictionary: ')
print(sorted_dict)
Posted by: Guest on August-07-2021

Code answers related to "python dictionary print key value ascending order"

Python Answers by Framework

Browse Popular Code Answers by Language