Commit bf644b2
committed
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 test1 parent 7b5e704 commit bf644b2
2 files changed
Lines changed: 36 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
7 | 9 | | |
8 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
9 | 21 | | |
10 | | - | |
11 | | - | |
| 22 | + | |
| 23 | + | |
12 | 24 | | |
13 | 25 | | |
14 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
15 | 30 | | |
16 | 31 | | |
17 | | - | |
| 32 | + | |
| 33 | + | |
18 | 34 | | |
19 | 35 | | |
20 | 36 | | |
21 | 37 | | |
22 | 38 | | |
23 | | - | |
24 | 39 | | |
25 | 40 | | |
26 | 41 | | |
27 | | - | |
28 | | - | |
| 42 | + | |
29 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
30 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
31 | 52 | | |
32 | 53 | | |
33 | | - | |
| 54 | + | |
34 | 55 | | |
35 | 56 | | |
36 | 57 | | |
| 58 | + | |
37 | 59 | | |
38 | 60 | | |
39 | | - | |
| 61 | + | |
40 | 62 | | |
41 | 63 | | |
42 | 64 | | |
| |||
71 | 93 | | |
72 | 94 | | |
73 | 95 | | |
74 | | - | |
| 96 | + | |
75 | 97 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| |||
66 | 67 | | |
67 | 68 | | |
68 | 69 | | |
| 70 | + | |
69 | 71 | | |
70 | 72 | | |
71 | 73 | | |
| |||
121 | 123 | | |
122 | 124 | | |
123 | 125 | | |
| 126 | + | |
124 | 127 | | |
125 | 128 | | |
126 | 129 | | |
| |||
0 commit comments