📜  按值排序字典 - 无论代码示例

📅  最后修改于: 2022-03-11 15:00:14.384000             🧑  作者: Mango

代码示例2
x = {1: 2, 3: 4, 4: 3, 2: 1, 0: 0}
{k: v for k, v in sorted(x.items(), key=lambda item: item[1])}
{0: 0, 2: 1, 1: 2, 4: 3, 3: 4}