📜  python字典打印键值升序 - Python代码示例

📅  最后修改于: 2022-03-11 14:45:37.209000             🧑  作者: Mango

代码示例1
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)