所以,如果我有3个字典:
dictionary = {'id':879, 'data':{'price': 18.90, 'location':'london', 'zipcode':'ha30ds'}}
dictionary2 = {'id':871, 'data':{'price': 24.00, 'location':'paris', 'zipcode':'nw93uo'}}
dictionary3 = {'id':873, 'data':{'price': 17.00, 'paris':'london', 'zipcode':'nw34kh'}}
并将它们放在列表中:
list = [dictionary,dictionary2,dictionary3]
其中
list[0]['data']['price'] == 18.90
我想按价格对字典列表进行排序。... 我尝试过:
newlist = sorted(list, key=['lambda'] k: k['data']['price'])
但这不起作用。...有什么想法吗?