From b8bc136fb9483abba3f478e272b0fa3e91306a2b Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sat, 5 Sep 2026 18:14:02 +0300 Subject: [PATCH] gh-135623: Document that json sorts the keys before coercing them to strings 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 5e8c452a5ab9a1..ddd12a002f7416 100644 --- a/Doc/library/json.rst +++ b/Doc/library/json.rst @@ -261,6 +261,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, \