Skip to content

Instantly share code, notes, and snippets.

@ikegami-yukino
Last active May 20, 2018 06:06
Show Gist options
  • Save ikegami-yukino/d51d71d587224292beed5a6aaf5aecfe to your computer and use it in GitHub Desktop.
Save ikegami-yukino/d51d71d587224292beed5a6aaf5aecfe to your computer and use it in GitHub Desktop.
def quicksort(x):
if not x:
return []
pivot = x[0]
smaller = quicksort([a for a in x[1:] if a <= pivot])
bigger = quicksort([a for a in x[1:] if a > pivot])
return(smaller + [pivot] + bigger)
x = [10, 2, 5, 3, 1, 6, 7, 4, 2, 3, 4, 8, 9]
print(quicksort(x))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment