python———sort、sorted使用(对dict排序)

1、L.sort(cmp=None,key=None,reverse=False)对L原地排序不会返回新的L sort使用: 一、key参数定义python L=[{2:8,3:5},{1:8,2:5,3:6,4:7},{1:5,2:9,3:6}] def f(x): return len(L) L.sort(key=f) print(L) 结果: [{2: 8, 3: 5}, {1: 5
相关文章
相关标签/搜索