Python Lambda 的神操作排序列表

看看牛x的排序方法 和Excel一样简单

list =[{'name':'mike','profession':'dir','age':'35'},
          {'name':'will','profession':'work','age':'20'},
          {'name':'mia','profession':'manager','age':'18'}]
order = list.sort(key = lambda x:x['age'])
print (list)

#输出结果
[{'name': 'mia', 'profession': 'manager', 'age': '18'}, {'name': 'will', 'profession': 'work', 'age': '20'}, {'name': 'mike', 'profession': 'dir', 'age': '35'}]