python dict list 字典数组 根据某个key的值排序
# encoding: utf-8
dictlist = [
{‘id’:’4′,’name’:’b’},
{‘id’:’6′,’name’:’c’},
{‘id’:’3′,’name’:’a’},
{‘id’:’1′,’name’:’g’},
{‘id’:’8′,’name’:’f’}
]
dictlist = sorted(dictlist, key=lambda k: k[‘id’], reverse=True)
print dictlist