Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

empty list returned without sorting #25

Merged
merged 4 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 2 additions & 2 deletions src/listwiz/sorting.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def merge_sort(l):
sorted_list
"""
# If there is a single item, the list is already sorted, return.
if len(l) == 1:
if len(l) <= 1:
return l

split = len(l) // 2
Expand Down Expand Up @@ -53,4 +53,4 @@ def bubble_sort(l):

def selection_sort(l):
# We should provide selection sort.
raise NotImplementedError
raise NotImplementedError
7 changes: 4 additions & 3 deletions tests/test_sorting.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ def test_mergesort():


def test_mergesort_empty():
# Stub for a test with empty lists, see issue #8
pass

# Test with empty list:
l = []
res = lws.merge_sort(l)
assert res == []

def test_bubble_sort():
# Stub for basic bubble sort tests, see issue #9
Expand Down