【发布时间】:2014-04-11 11:28:03
【问题描述】:
这是字典的样子:
{'57481': 50, '57480': 89, '57483': 110, '57482': 18, '57485': 82, '57484': 40}
我想按数字顺序对字典进行排序,结果应该是:
{'57480': 89, '57481': 50, '57482': 18, '57483': 110, '57484': 40, '57485': 82}
我尝试了sorted(self.docs_info.items),但它不起作用。
【问题讨论】:
-
这能回答你的问题吗? How can I sort a dictionary by key?
标签: python sorting dictionary