Skip to content

Instantly share code, notes, and snippets.

@nikolak
Created September 3, 2014 09:25
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 nikolak/0e047e470c1e5560c7cb to your computer and use it in GitHub Desktop.
Save nikolak/0e047e470c1e5560c7cb to your computer and use it in GitHub Desktop.
def quicksort(array):
if len(array) <= 1:
return array
pivot = array[0]
array.remove(pivot)
less, greater = [], []
for x in array:
if x <= pivot:
less.append(x)
else:
greater.append(x)
return (quicksort(less) + [pivot] + quicksort(greater))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment