Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6474041

Browse files
gh-135623: Document that json sorts the keys before coercing them to strings (GH-156987)
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
1 parent 62cbd34 commit 6474041

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

Doc/library/json.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,8 @@ Basic Usage
261261
into JSON and then back into a dictionary, the dictionary may not equal
262262
the original one. That is, ``loads(dumps(x)) != x`` if x has non-string
263263
keys.
264+
*sort_keys* sorts the keys before they are coerced to strings,
265+
so numeric keys are sorted by value, not by their string representation.
264266

265267
.. function:: load(fp, *, cls=None, object_hook=None, parse_float=None, \
266268
parse_int=None, parse_constant=None, \

0 commit comments

Comments
 (0)