Repository navigation
Preserve equal-key value order in sortedvalues - #701
Open
Gambit-Checkmate wants to merge 1 commit into
Open
Gambit-Checkmate wants to merge 1 commit into
Gambit-Checkmate wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The change
Fixes #700.
OrderedMultiDict.sortedvaluessorts each key's values in the requested direction and then consumes that sorted group forwards. This preserves the insertion order of equal-key values in both directions, matching Python's stable sort, while preserving every original key position. The former opposite-direction sort followed bypop()also reversed ties.Mirror the fix in the embedded
urlutils.OrderedMultiDict, coveringQueryParamDictand parsed URL query parameters. Clarify that the key callback receives a value, and document tie stability. Add an unreleased changelog entry; no dependency or version change.Validation on Windows / CPython 3.13.13:
d31d821and pass after the fix. They cover both sort directions,OrderedMultiDict,FastIterOrderedMultiDict,QueryParamDictand parsed URL queries; assert key positions, input preservation, value identity and one callback invocation per value.git diff --check, source distribution and wheel build: passed.No coverage percentage is claimed. Other interpreters/platforms have not been run locally. Hosted Tests run 41269961822 requires upstream approval (
action_required); no hosted tests have executed.The backstory
Previous contribution context: #601, folded into #609. This defect was found by source inspection while checking the ordering guarantees of
sortedvalues, not through production use. The issue contains a minimal reproduction; I checked the current open PR inventory and all-statesortedvalues/stable-sort searches before reporting it.AI assistance
Harness/tooling: OpenAI Codex, GitHub CLI, Python/pytest and Ruff.
Model(s): GPT-6 family; exact deployment identifier unavailable.
Original prompt(s), relevant excerpts from the recurring user instruction, kept verbatim (the full instruction also includes private local workflow details):
The agent selected the specific defect, prepared the implementation and tests, and ran the checks above. No production usage or independent human code review is claimed.