Skip to content

sorts: type cocktail shaker sort for comparable items - #15278

Open
ElenaGe216 wants to merge 1 commit into
TheAlgorithms:masterfrom
ElenaGe216:15234/typing/cocktail-shaker-sort
Open

sorts: type cocktail shaker sort for comparable items#15278
ElenaGe216 wants to merge 1 commit into
TheAlgorithms:masterfrom
ElenaGe216:15234/typing/cocktail-shaker-sort

Conversation

@ElenaGe216

Copy link
Copy Markdown

Part of #15234

Describe your change

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Add or change doctests? -- Note: Please avoid changing both code and tests in a single pull request.
  • Documentation change?

Summary

Type cocktail_shaker_sort for mutually comparable values instead of only integers. The implementation is unchanged; its signature now preserves the element type, its doctest records the mixed-type TypeError contract, and the existing shared rejection test now covers it.

Testing

  • python3 -m doctest -v sorts/cocktail_shaker_sort.py: 8 passed
  • uvx pytest sorts/cocktail_shaker_sort.py tests/test_sorts.py --doctest-modules: 231 passed
  • uvx ruff check and uvx ruff format --check: passed
  • uvx ty check sorts/cocktail_shaker_sort.py: passed
  • uvx pre-commit run --all-files: passed

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.
  • This PR uses a closing keyword for sorts: make algorithms sort any comparable items, not just ints #15234. This is intentionally unchecked because sorts: make algorithms sort any comparable items, not just ints #15234 is a tracking issue that must remain open until all algorithms are completed.

@algorithms-keeper algorithms-keeper Bot added awaiting reviews This PR is ready to be reviewed enhancement This PR modified some existing files labels Sep 11, 2026
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 enhancement This PR modified some existing files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants