Skip to content

sorts: type stooge_sort for any comparable items - #15346

Merged
cclauss merged 1 commit into
TheAlgorithms:masterfrom
itsnevu:sorts/stooge-sort-comparable
Sep 18, 2026
Merged

cclauss merged 1 commit into
TheAlgorithms:masterfrom
itsnevu:sorts/stooge-sort-comparable

Conversation

@itsnevu

@itsnevu itsnevu commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Describe your change

Makes stooge_sort (and its stooge helper) generic over any Comparable items instead of list[int], following the already-merged insertion_sort.py pattern (a Comparable Protocol plus a [T: Comparable] type parameter). The one comparison used a > b, rewritten as b < a so items only need __lt__.

Part of #15234 (using "Part of", not a closing keyword, so the umbrella issue stays open).

  • Fix a bug or typo in an existing algorithm?
  • Add or change doctests?

Checklist

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing. New doctests cover a str list, a float/int mix, and a pytest.raises(TypeError) for non-comparable input.

@algorithms-keeper algorithms-keeper Bot added awaiting reviews This PR is ready to be reviewed enhancement This PR modified some existing files labels Sep 15, 2026
@cclauss

cclauss commented Sep 15, 2026

Copy link
Copy Markdown
Member

ON HOLD: Our focus is on merging or closing old pull requests before October 1st.

@algorithms-keeper algorithms-keeper Bot removed the awaiting reviews This PR is ready to be reviewed label Sep 18, 2026
@cclauss
cclauss merged commit 4d05248 into TheAlgorithms:master Sep 18, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement This PR modified some existing files on hold

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants