Leif160519的blog Leif160519的blog

——————

目录
Python 针对Json中某个关键字段进行排序
/  

Python 针对Json中某个关键字段进行排序

示例

json_array = [{"time":20150312,"value":"c"}, {"time":20150301,"value":"a"}, {"time":20150305,"value":"b"}]
json_array.sort(key = lambda x:x["time"])

运行结果:

print(json_array)
[{'value': 'a', 'time': 20150301},
{'value': 'b', 'time': 20150305},
{'value': 'c', 'time': 20150312}]

“The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time.” – Tom Cargill

标  题Python 针对Json中某个关键字段进行排序
作  者Leif160519
出  处https://github.icu/articles/2019/10/08/1570518536137.html
关于博主:坐标南京,运维工程师,如有问题探讨可以直接下方留言。
声援博主:如果您觉得文章对您有帮助,可以评论、订阅、收藏。您的鼓励是博主的最大动力!