-
-
Save rochacbruno/50bd58495a88192549a6 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(v): | |
if len(v) <= 1: | |
return v | |
pivot = v[0] | |
equals = [x for x in v if x == pivot] | |
smaller = [x for x in v if x < pivot] | |
higher = [x for x in v if x > pivot] | |
return quicksort(smaller) + equals + quicksort(higher) | |
print (quicksort([5, 7, 9, 3, 4, 0, 2, 1, 6, 8])) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment