diff --git a/sorts/tim_sort.py b/sorts/tim_sort.py index 2eeed88b7399..c6da6c4fafa9 100644 --- a/sorts/tim_sort.py +++ b/sorts/tim_sort.py @@ -52,8 +52,12 @@ def tim_sort(lst: list[Any] | tuple[Any, ...] | str) -> list[Any]: True >>> tim_sort([3, 2, 1]) == sorted([3, 2, 1]) True + >>> tim_sort([]) + [] """ length = len(lst) + if length == 0: + return [] runs, sorted_runs = [], [] new_run = [lst[0]] sorted_array: list[Any] = []