This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Aaron Hall
Recipients Aaron Hall, josh.r, r.david.murray, tanzer@swing.co.at, zachrahan
Date 2018-05-21.17:26:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1526923593.06.0.682650639539.issue25457@psf.upfronthosting.co.za>
In-reply-to
Content
From a design standpoint, I'm fairly certain the sort_keys argument was created due to Python's dicts being arbitrarily ordered.

Coercing to strings before sorting is unsatisfactory because, e.g. numbers sort lexicographically instead of by numeric value when strings.

>>> import json
>>> json.dumps({i:i**2 for i in range(15)}, sort_keys=True)
'{"0": 0, "1": 1, "2": 4, "3": 9, "4": 16, "5": 25, "6": 36, "7": 49, "8": 64, "9": 81, "10": 100, "11": 121, "12": 144, "13": 169, "14": 196}'
>>> json.dumps({str(i):i**2 for i in range(15)}, sort_keys=True)
'{"0": 0, "1": 1, "10": 100, "11": 121, "12": 144, "13": 169, "14": 196, "2": 4, "3": 9, "4": 16, "5": 25, "6": 36, "7": 49, "8": 64, "9": 81}'

Changing the order of operations is just going to create more issues, IMHO.

Now that users can sort their dicts prior to providing them to the function, e.g.:

>>> json.dumps({str(i):i**2 for i in range(15)})
'{"0": 0, "1": 1, "2": 4, "3": 9, "4": 16, "5": 25, "6": 36, "7": 49, "8": 64, "9": 81, "10": 100, "11": 121, "12": 144, "13": 169, "14": 196}'

we could deprecate the argument, or just keep it as-is for hysterical raisins.

Regardless, I'd close this as "won't fix".
History
Date User Action Args
2018-05-21 17:26:33Aaron Hallsetrecipients: + Aaron Hall, zachrahan, r.david.murray, josh.r, tanzer@swing.co.at
2018-05-21 17:26:33Aaron Hallsetmessageid: <1526923593.06.0.682650639539.issue25457@psf.upfronthosting.co.za>
2018-05-21 17:26:33Aaron Halllinkissue25457 messages
2018-05-21 17:26:32Aaron Hallcreate