sorting left-half and right-half individually then merging them into result
(input_list: list, low: int, mid: int, high: int)
| 13 | |
| 14 | |
| 15 | def merge(input_list: list, low: int, mid: int, high: int) -> list: |
| 16 | """ |
| 17 | sorting left-half and right-half individually |
| 18 | then merging them into result |
| 19 | """ |
| 20 | result = [] |
| 21 | left, right = input_list[low:mid], input_list[mid : high + 1] |
| 22 | while left and right: |
| 23 | result.append((left if left[0] <= right[0] else right).pop(0)) |
| 24 | input_list[low : high + 1] = result + left + right |
| 25 | return input_list |
| 26 | |
| 27 | |
| 28 | # iteration over the unsorted list |
no test coverage detected