sorting a list of dictionary values by date in python

后端 未结 5 1250
遥遥无期
遥遥无期 2020-12-24 13:29

I have a list and I am appending a dictionary to it as I loop through my data...and I would like to sort by one of the dictionary keys.

ex:

data = \         


        
5条回答
  •  醉梦人生
    2020-12-24 14:08

    Sort the data (or a copy of the data) directly and build the list of dicts afterwards. Sort using the function sorted with an appropiate key function (operator.attrgetter probably)

提交回复
热议问题