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