From a514afcc5c7de8e843ca153d4da38940dbd91ac6 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sun, 13 Sep 2026 11:04:50 +0300 Subject: [PATCH] gh-135623: Document that json sorts the keys before coercing them to strings (GH-156987) (cherry picked from commit 64740410909891331eb4e4cbdb14837ff4f8ec64) Co-authored-by: Serhiy Storchaka Co-authored-by: Claude Opus 5 (1M context) --- Doc/library/json.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Doc/library/json.rst b/Doc/library/json.rst index 231654a3a9315f3..3632cec2df72a3b 100644 --- a/Doc/library/json.rst +++ b/Doc/library/json.rst @@ -264,6 +264,8 @@ Basic Usage into JSON and then back into a dictionary, the dictionary may not equal the original one. That is, ``loads(dumps(x)) != x`` if x has non-string keys. + *sort_keys* sorts the keys before they are coerced to strings, + so numeric keys are sorted by value, not by their string representation. .. function:: load(fp, *, cls=None, object_hook=None, parse_float=None, \ parse_int=None, parse_constant=None, \