* sorts: make recursive_insertion_sort generic over Comparable items
Part of #15234
- switch rec_insertion_sort/insert_next to the Comparable/TypeVar-bound
MutableSequence[T] pattern (in-place sorts bucket) per the convention
discussed on #15234
- make rec_insertion_sort return the sorted collection and give n a
default of len(collection), so it can be called with a single
argument like the other sorts in the shared test battery
- add a string doctest
- register rec_insertion_sort in tests/test_sorts.py's shared SORTS
battery and the non-comparable-items rejection test
* fix: keep rec_insertion_sort in-place with None return, per maintainer review
- Revert n to a required parameter and drop the MutableSequence[T] return
value; rec_insertion_sort stays a pure in-place sort returning None, as
requested in review.
- Keep the Comparable/TypeVar generalization (no PEP 695 syntax, to match
the existing TypeVar style in the file).
- Keep the non-int (string) doctest.
- tests/test_sorts.py: rec_insertion_sort no longer fits the shared SORTS
battery (which asserts on a returned value), so it's removed from that
tuple and given its own parametrized in-place test, plus its own
non-comparable-items rejection test.
* test: adjust test_sorts.py for rec_insertion_sort's None-returning in-place contract
rec_insertion_sort no longer fits the shared SORTS battery (which asserts
on a returned value), so it's removed from that tuple and given its own
parametrized in-place test (checked against sorted()) plus its own
non-comparable-items rejection test.
* Apply batched suggestions from code review
Co-authored-by: Christian Clauss <cclauss@me.com>
---------
Co-authored-by: Christian Clauss <cclauss@me.com>
* [mypy] Add/fix type annotations for recursive_insertion_sort(#4085)
* [mypy] Add/fix type annotations for bucket_sort(#4085)
* [mypy] Reworked code for cocktail_shaker_sort so that missing return statement error is resolved(#4085)
* [mypy] Add/fix type annotations for patience_sort(#4085)
* [mypy] Add/fix type annotations for radix_sort(#4085)
Co-authored-by: goodm2 <4qjpngu8mem8cz>