From 410f9acf4ee2dc6fa5e91fb3ea9ceec63ccc6a35 Mon Sep 17 00:00:00 2001 From: AsparkArcane Date: Sat, 18 Oct 2025 20:50:10 +0530 Subject: [PATCH] feat: master-controller --- sort.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/sort.py b/sort.py index 402e60c..db1eda6 100644 --- a/sort.py +++ b/sort.py @@ -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'." + )