Skip to content

types(power_sort): preserve input item type - #15488

Merged
cclauss merged 4 commits into
TheAlgorithms:masterfrom
nightcityblade:fix/issue-15234-power-sort
Oct 5, 2026
Merged

cclauss merged 4 commits into
TheAlgorithms:masterfrom
nightcityblade:fix/issue-15234-power-sort

Conversation

@nightcityblade

@nightcityblade nightcityblade commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Preserve the input item type throughout PowerSort and its internal helpers.
  • Accept any iterable, matching the algorithm's existing copy-before-sort behavior.
  • Add PowerSort to the shared comparable-items and mixed-type regression tests.

Part of #15234 (intentionally not closing the tracking issue).

Tests

  • uv run --no-sync pytest sorts/power_sort.py tests/test_sorts.py --doctest-modules -q (459 passed)
  • uvx pre-commit run --all-files --show-diff-on-failure
  • uvx ty check sorts/power_sort.py tests/test_sorts.py

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?

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 new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • 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.
  • All new algorithms include at least one URL that points to Wikipedia or another similar explanation.
  • If this pull request resolves one or more open issues, then the description above includes the issue number(s) with a closing keyword: "Fixes #ISSUE-NUMBER".

N/A for the final item: #15234 explicitly requests Part of #15234 without a closing keyword because it tracks multiple algorithms.

@algorithms-keeper algorithms-keeper Bot added awaiting reviews This PR is ready to be reviewed enhancement This PR modified some existing files labels Oct 3, 2026
@algorithms-keeper algorithms-keeper Bot added awaiting reviews This PR is ready to be reviewed and removed awaiting reviews This PR is ready to be reviewed labels Oct 3, 2026
@nightcityblade
nightcityblade force-pushed the fix/issue-15234-power-sort branch from 026d5b9 to bb40379 Compare October 5, 2026 03:41
@nightcityblade

Copy link
Copy Markdown
Contributor Author

Rebuilt the approved change on current master to resolve the conflict. The 459 focused tests, full pre-commit suite, and Ty all pass.

Added examples for using power_sort with tuples and lists.
@algorithms-keeper algorithms-keeper Bot removed the awaiting reviews This PR is ready to be reviewed label Oct 5, 2026
@algorithms-keeper algorithms-keeper Bot added the awaiting reviews This PR is ready to be reviewed label Oct 5, 2026
@cclauss
cclauss merged commit 8747434 into TheAlgorithms:master Oct 5, 2026
5 checks passed
@algorithms-keeper algorithms-keeper Bot removed the awaiting reviews This PR is ready to be reviewed label Oct 5, 2026
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants