9.请按alist中元素的age由大到小排序
xingdongzhe opened this issue · 1 comments
xingdongzhe commented
使用itemgetter 更优雅
from operator import itemgetter
alist = [{'name': 'a', 'age': 20}, {'name': 'b', 'age': 30}, {'name': 'c', 'age': 25}]
alist_sorted = sorted(alist, key=itemgetter('age'), reverse=True)
kenwoodjw commented
可以提交pr