[issue38414] Ordering a nested dictionary in python with json format

2019-10-08 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Dictionary preserve the insertion order starting from Python 3.7 (actually from 3.6, but it was not guarantied). I am surprised that you got different result in 3.6. I cannot reproduce it. In older Python versions you can pass object_pairs_hook=OrderedDict

[issue38414] Ordering a nested dictionary in python with json format

2019-10-08 Thread Umar Asghar
Change by Umar Asghar : -- type: -> enhancement ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail

[issue38414] Ordering a nested dictionary in python with json format

2019-10-08 Thread Umar Asghar
Umar Asghar added the comment: Please ignore the above shared sample data in the above code and consider this one. this is the exact code that is misbehaving in python 2.7 # Sort nested dictionary by key # using OrderedDict() + sorted() from collections import OrderedDict from operator impo

[issue38414] Ordering a nested dictionary in python with json format

2019-10-08 Thread Umar Asghar
Change by Umar Asghar : -- versions: +Python 2.7 -Python 3.9 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue38414] Ordering a nested dictionary in python with json format

2019-10-08 Thread Umar Asghar
Umar Asghar added the comment: I have recently attached the file, please review it as a code reference. -- ___ Python tracker ___ _

[issue38414] Ordering a nested dictionary in python with json format

2019-10-08 Thread Umar Asghar
Change by Umar Asghar : Added file: https://bugs.python.org/file48649/test.py ___ Python tracker ___ ___ Python-bugs-list mailing list Unsub

[issue38414] Ordering a nested dictionary in python with json format

2019-10-08 Thread Umar Asghar
Umar Asghar added the comment: I guess it exists in all Python versions. I have tested in both Python 2 and Python 3. Python 2.7.15+ (default, Jul 9 2019, 16:51:35) [GCC 7.4.0] on linux2 Python 3.6.8 (default, Aug 20 2019, 17:12:48) [GCC 8.3.0] on linux -- versions: +Python 3.9

[issue38414] Ordering a nested dictionary in python with json format

2019-10-08 Thread Umar Asghar
New submission from Umar Asghar : Python does not preserve ordering in JSON format. I have tested it out but it's not working. Here is my code. # Python3 code to demonstrate # Sort nested dictionary by key # using OrderedDict() + sorted() from collections import OrderedDict from operator i