Created
July 3, 2018 11:29
-
-
Save erika-dike/0f6bab769c891a1b9d4797317397f27e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def quicksort(alist): | |
if len(alist) < 2: | |
return alist | |
else: | |
pivot = alist[0] | |
less = [num for num in alist[1:] if num <= pivot] | |
greater = [num for num in alist[1:] if num > pivot] | |
return quicksort(less) + [pivot] + quicksort(greater) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment