python列表嵌套字典的排序 python列表嵌套字典排序?
python列表嵌套字典排序?L=[{“status”:1,“com”:“a”},{“status”:2,“com”:“C”},{“status”:1,“com”:“B”},{“status”:1,“
python列表嵌套字典排序?
L=[{“status”:1,“com”:“a”},{“status”:2,“com”:“C”},{“status”:1,“com”:“B”},{“status”:1,“com”:“a”}L.sort(key=lambda x:(-x[“status”],x[“com”])print L
Python的列表提供了一種排序方法,它還可以使用Python的內(nèi)置排序來獲取新的排序列表。
示例:
a=[1,3,2
]打?。ㄅ判颍╝))
a.排序()
打印(a)