Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion sort.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,22 @@ def sort(data: List[Any], comparator: Callable[[Any, Any], bool], method: str =
Raises:
ValueError: If an unknown sort method is provided.
"""
pass
# Normalize the method name for case-insensitive comparison
method_lower = method.lower()

# Dispatch to the correct sorting algorithm
if method_lower == "merge":
return Sorter.merge(data, comparator)

elif method_lower == "insertion":
return Sorter.insertion(data, comparator)

elif method_lower == "bubble":
return Sorter.bubble(data, comparator)

else:
# Handle unknown sort methods
raise ValueError(
f"Unknown sort method '{method}'. Choose 'merge', 'insertion', or 'bubble'."
)