-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
from collections import OrderedDict>>>>>> json_data = {... "11": {... "j_id": "out",... },... "aa": {... "j_id": "in",... },... "bb": {... "j_id": "out",... },... }>>>>>> jkeys=json_data.keys()>>> sorted_json = sorted(jkeys, key=lambda x: json_data[x]['j_id'], reverse=False)>>>>>> new_sorted=OrderedDict()>>> for rec in sorted_json:... new_sorted[rec]=json_data[rec]...>>> print('sort dict: {}'.format(new_sorted))sort dict: OrderedDict([('aa', {'j_id': 'in'}), ('11', {'j_id': 'out'}), ('bb', {'j_id': 'out'})]) ``` Unfortunately, when I pass this to jsonify() function and then for example console.log() output of flask data, the orderd becomes like that: 11, aa, bb. Additionally to that, I've done some research and found this stackoverflow answer, leading to some good documentation notes which clearly states that setting JSON_SORT_KEYS to False is not recommended way. Then I checked this github issue and it seems that problem is not fully resolved in flask.