-
Notifications
You must be signed in to change notification settings - Fork 6
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
Conversation
src/listwiz/sorting.py
Outdated
@@ -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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)
Of course there should be a test :-) After all, there was already a stub. |
Thank you gertingold 😄 @seberg should we fix the merge conflict and merge? |
Yap, looks all good to me, thanks. Can't even find a nitpick :). |
Thanks @gertingold. |
This PR proposes to handle empty lists like lists of length 1 and to return the list unmodified. This solution should fix #8