diff --git a/sorts/tree_sort.py b/sorts/tree_sort.py index 056864957d4d..be137bae4fee 100644 --- a/sorts/tree_sort.py +++ b/sorts/tree_sort.py @@ -1,12 +1,11 @@ """ Tree_sort algorithm. - Build a Binary Search Tree and then iterate thru it to get a sorted list. """ from __future__ import annotations -from collections.abc import Iterator +from collections.abc import Iterable, Iterator from dataclasses import dataclass @@ -39,7 +38,7 @@ def insert(self, val: int) -> None: self.right.insert(val) -def tree_sort(arr: list[int]) -> tuple[int, ...]: +def tree_sort(arr: Iterable[int]) -> tuple[int, ...]: """ >>> tree_sort([]) () @@ -54,8 +53,8 @@ def tree_sort(arr: list[int]) -> tuple[int, ...]: >>> tree_sort([5, 6, 1, -1, 4, 37, 2, 7]) (-1, 1, 2, 4, 5, 6, 7, 37) - # >>> tree_sort(range(10, -10, -1)) == tuple(sorted(range(10, -10, -1))) - # True + >>> tree_sort(range(10, -10, -1)) == tuple(sorted(range(10, -10, -1))) + True """ if len(arr) == 0: return tuple(arr)