Skip to content

Commit a514afc

Browse files
serhiy-storchakaclaude
authored andcommitted
gh-135623: Document that json sorts the keys before coercing them to strings (GH-156987)
(cherry picked from commit 6474041) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 28fbedc commit a514afc

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
@@ -264,6 +264,8 @@ Basic Usage
264264
into JSON and then back into a dictionary, the dictionary may not equal
265265
the original one. That is, ``loads(dumps(x)) != x`` if x has non-string
266266
keys.
267+
*sort_keys* sorts the keys before they are coerced to strings,
268+
so numeric keys are sorted by value, not by their string representation.
267269

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

0 commit comments

Comments
 (0)