diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..24ee5b1 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.13 diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..184c4eb --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,11 @@ +{ + "python.testing.unittestArgs": [ + "-v", + "-s", + ".", + "-p", + "test_*.py" + ], + "python.testing.pytestEnabled": false, + "python.testing.unittestEnabled": true +} \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..146ebc6 --- /dev/null +++ b/main.py @@ -0,0 +1,6 @@ +def main(): + print("Hello from sort-quest!") + + +if __name__ == "__main__": + main() diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..af6f9c1 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,9 @@ +[project] +name = "sort-quest" +version = "0.1.0" +description = "Add your description here" +readme = "README.md" +requires-python = ">=3.13" +dependencies = [ + "colorful-test>=1.0.2", +] diff --git a/sort.py b/sort.py index 402e60c..bab38f6 100644 --- a/sort.py +++ b/sort.py @@ -12,17 +12,27 @@ class Sorter: @staticmethod def merge(data: List[Any], comparator: Callable[[Any, Any], bool]) -> List[Any]: - """ - Sorts the list using the merge sort algorithm. - Args: - data (List[Any]): The list to sort. - comparator (Callable[[Any, Any], bool]): Comparison function. - - Returns: - List[Any]: A new sorted list. - """ - pass + + if len(data) <= 1: + return data + + mid = len(data) // 2 + left = Sorter.merge(data[:mid], comparator) + right = Sorter.merge(data[mid:], comparator) + merged = [] + i = 0 + j = 0 + while i < len(left) and j < len(right): + if comparator(left[i], right[j]): + merged.append(left[i]) + i += 1 + else: + merged.append(right[j]) + j += 1 + merged.extend(left[i:]) + merged.extend(right[j:]) + return merged @staticmethod def insertion(data: List[Any], comparator: Callable[[Any, Any], bool]) -> List[Any]: diff --git a/uv.lock b/uv.lock new file mode 100644 index 0000000..8ce8a3b --- /dev/null +++ b/uv.lock @@ -0,0 +1,23 @@ +version = 1 +revision = 3 +requires-python = ">=3.13" + +[[package]] +name = "colorful-test" +version = "1.0.2" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/be/95/a4b7f6afb80c756f57abfa980b539bc117ba341e9ccdae6550109b56af7e/colorful_test-1.0.2.tar.gz", hash = "sha256:0f9a13fd92f1bc2eb35099b35a25970afb4cb230f15d9071485ff6bc6e6cf739", size = 15358, upload-time = "2025-02-07T15:27:54.376Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/6d/6f/596dfc5c26f744def6b6d5882cd0aa766ab6822d90c20fbe00a59b487f07/colorful_test-1.0.2-py3-none-any.whl", hash = "sha256:8037811ccdcf2d91724d691dbe430559aa1e92f5d8b702ce8d76a741051464e7", size = 14842, upload-time = "2025-02-07T15:27:52.098Z" }, +] + +[[package]] +name = "sort-quest" +version = "0.1.0" +source = { virtual = "." } +dependencies = [ + { name = "colorful-test" }, +] + +[package.metadata] +requires-dist = [{ name = "colorful-test", specifier = ">=1.0.2" }]