how to keep order of sorted dictionary passed to jsonify() function?

This page summarizes the projects mentioned and recommended in the original post on /r/codehunter

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.
www.influxdata.com
featured
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com
featured
  • Flask

    The Python micro framework for building web applications.

  • 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.

  • 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.

    InfluxDB logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • How do you iterate on a library built locally?

    1 project | /r/learnpython | 1 Aug 2023
  • Web/Desktop App

    1 project | /r/devpt | 11 Apr 2023
  • python help

    1 project | /r/Python | 25 Mar 2023
  • How to Create a Simple Web App with Python and Flask in 8 Easy Steps

    1 project | dev.to | 23 Mar 2023
  • Flask (factory) + Celery

    1 project | /r/flask | 27 Jan 2023