草稿 · 2022年4月30日 0

草稿:Python-排序字典值

定义变量:
xs = {'a': 4, 'b': 3, 'c': 2, 'd': 1}
使用sorted+lambda:
sorted(xs.items(), key=lambda x: x[1])
``` 

##### 使用第三方库:

```python
import operator
sorted(xs.items(), key=operator.itemgetter(1))