In this article, the example of Python implementation for a key field in the json sorting operation. Shared for your reference, as follows:
Example:
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)
Run results:
[{'value': 'a', 'time': 20150301},
{'value': 'b', 'time': 20150305},
{'value': 'c', 'time': 20150312}]
The results of the local shell environment test are as follows:
PS: Here we recommend a few more practical json online tools for your reference:
on-lineJSONCode checking, inspection, beautification and formatting tools:
http://tools./code/json
JSONOnline formatting tool:
http://tools./code/jsonformat
Online XML/JSONInterconversion tool:
http://tools./code/xmljson
jsonCode online formatting/beautification/compression/editing/conversion tool:
http://tools./code/jsoncodeformat
on-linejsonCompression/Endorsing Tool:
http://tools./code/json_yasuo_trans
For more Python related content, readers can check out this site's topic:Python manipulation json skills summary》、《Summary of Python coding manipulation techniques》、《Python Data Structures and Algorithms Tutorial》、《Summary of Python function usage tips》、《Summary of Python string manipulation techniques》、《Python introductory and advanced classic tutorialsand theSummary of Python file and directory manipulation techniques》
I hope the description of this article will help you in Python programming.