标签:
举例:
import operator
x = [{‘name‘:‘Homer‘, ‘age‘:39}, {‘name‘:‘Bart‘, ‘age‘:10}] sorted_x = sorted(x, key=operator.itemgetter(‘name‘))
print sorted_x
----------------------------- [{‘age‘: 10, ‘name‘: ‘Bart‘}, {‘age‘: 39, ‘name‘: ‘Homer‘}]
python 字典列表排序operator.itemgetter()
标签:
原文地址:http://www.cnblogs.com/nzyjlr/p/5512729.html