📌  相关文章
📜  python 按值对字典进行排序 - Python 代码示例

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

代码示例4
>>> d = {"aa": 3, "bb": 4, "cc": 2, "dd": 1}
>>> for k in sorted(d, key=d.get, reverse=True):
...     k, d[k]
...
('bb', 4)
('aa', 3)
('cc', 2)
('dd', 1)