Last active
May 20, 2018 06:06
-
-
Save ikegami-yukino/d51d71d587224292beed5a6aaf5aecfe to your computer and use it in GitHub Desktop.
This file contains 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(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