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
Changes from 1 commit
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 0 <= len(l) <= 1:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if 0 <= len(l) <= 1:
if len(l) <= 1:

I think it would be clearer to delete this, since the length cannot be negative.

(since it is a small change, one can just apply it. Often I would just do that as a maintainer)

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