Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.13
11 changes: 11 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"python.testing.unittestArgs": [
"-v",
"-s",
".",
"-p",
"test_*.py"
],
"python.testing.pytestEnabled": false,
"python.testing.unittestEnabled": true
}
6 changes: 6 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
def main():
print("Hello from sort-quest!")


if __name__ == "__main__":
main()
9 changes: 9 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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",
]
30 changes: 20 additions & 10 deletions sort.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down
23 changes: 23 additions & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.