Skip to content

sorts: type reversort for any comparable items - #15348

Closed
itsnevu wants to merge 1 commit into
TheAlgorithms:masterfrom
itsnevu:sorts/reversort-comparable
Closed

itsnevu wants to merge 1 commit into
TheAlgorithms:masterfrom
itsnevu:sorts/reversort-comparable

Conversation

@itsnevu

@itsnevu itsnevu commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Describe your change

Makes reversort (and reversort_cost) generic over any Comparable items instead of list[Any], following the already-merged insertion_sort.py pattern (a Comparable Protocol plus a [T: Comparable] type parameter). It already compares with < only, so items just 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. The file already had str and float doctests; this adds a pytest.raises(TypeError) case for non-comparable input.

@algorithms-keeper algorithms-keeper Bot added the awaiting reviews This PR is ready to be reviewed label Sep 15, 2026
@algorithms-keeper

Copy link
Copy Markdown

Multiple Pull Request Detected

@itsnevu, we are extremely excited that you want to submit multiple algorithms in this repository but we have a limit on how many pull request a user can keep open at a time. This is to make sure all maintainers and users focus on a limited number of pull requests at a time to maintain the quality of the code.

This pull request is being closed as the user already has an open pull request. Please focus on your previous pull request before opening another one. Thank you for your cooperation.

User opened pull requests (including this one): #15348, #15347, #15346, #15345

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting reviews This PR is ready to be reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant