Skip to content

Instantly share code, notes, and snippets.

@erika-dike
Created July 3, 2018 11:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erika-dike/0f6bab769c891a1b9d4797317397f27e to your computer and use it in GitHub Desktop.
Save erika-dike/0f6bab769c891a1b9d4797317397f27e to your computer and use it in GitHub Desktop.
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