MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / merge

Function merge

sorts/tim_sort.py:30–40  ·  view source on GitHub ↗
(left: list[Any], right: list[Any])

Source from the content-addressed store, hash-verified

28
29
30def merge(left: list[Any], right: list[Any]) -> list[Any]:
31 if not left:
32 return right
33
34 if not right:
35 return left
36
37 if left[0] < right[0]:
38 return [left[0], *merge(left[1:], right)]
39
40 return [right[0], *merge(left, right[1:])]
41
42
43def tim_sort(lst: list[Any] | tuple[Any, ...] | str) -> list[Any]:

Callers 2

patience_sortFunction · 0.70
tim_sortFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected