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

Skip to content

gh-135623: Document that json sorts the keys before coercing them to strings - #156987

Merged
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:json-sort-keys-docs
Sep 13, 2026
Merged

gh-135623: Document that json sorts the keys before coercing them to strings#156987
serhiy-storchaka merged 1 commit into
python:mainfrom
serhiy-storchaka:json-sort-keys-docs

Conversation

@serhiy-storchaka

Copy link
Copy Markdown
Member

sort_keys sorts the keys of a dictionary, not the strings written to the output, so numeric keys are sorted by value. This is not obvious, because the keys are coerced to strings, and re-dumping the loaded result gives a different order.

…em to strings

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@bedevere-app bedevere-app Bot added docs Documentation in the Doc dir skip news labels Sep 5, 2026
@github-project-automation github-project-automation Bot moved this to Todo in Docs PRs Sep 5, 2026
@serhiy-storchaka serhiy-storchaka added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Sep 5, 2026
@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #34408362 | 📁 Comparing b8bc136 against main (e620377)

  🔍 Preview build  

1 file changed
± library/json.html

@terryjreedy

Copy link
Copy Markdown
Member

LGTM

@serhiy-storchaka
serhiy-storchaka merged commit 6474041 into python:main Sep 13, 2026
42 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14, 3.15.
🐍🍒⛏🤖

@serhiy-storchaka
serhiy-storchaka deleted the json-sort-keys-docs branch September 13, 2026 08:04
@github-project-automation github-project-automation Bot moved this from Todo to Done in Docs PRs Sep 13, 2026
@bedevere-app

bedevere-app Bot commented Sep 13, 2026

Copy link
Copy Markdown

GH-157400 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 pre-release feature fixes, bugs and security fixes label Sep 13, 2026
@bedevere-app

bedevere-app Bot commented Sep 13, 2026

Copy link
Copy Markdown

GH-157401 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Sep 13, 2026
@bedevere-app

bedevere-app Bot commented Sep 13, 2026

Copy link
Copy Markdown

GH-157402 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 bugs and security fixes label Sep 13, 2026
serhiy-storchaka added a commit that referenced this pull request Sep 13, 2026
…hem to strings (GH-156987) (GH-157402)

(cherry picked from commit 6474041)

Co-authored-by: Serhiy Storchaka <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
serhiy-storchaka added a commit that referenced this pull request Sep 13, 2026
…hem to strings (GH-156987) (GH-157401)

(cherry picked from commit 6474041)

Co-authored-by: Serhiy Storchaka <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir skip news

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants