Sort Dictionary

student_scores = {
‘Alex’: 88,
‘Ben’: 75,
‘Cyrus’: 93,
‘Denver’: 85
}
sorted_by_values = dict(sorted(student_scores.items(), key=lambda item: item[1]))
print(sorted_by_values)

{‘Ben’: 75, ‘Denver’: 85, ‘Alex’: 88, ‘Cyrus’: 93}

原文链接:Sort Dictionary

© 版权声明
THE END
喜欢就支持一下吧
点赞10 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容