Created
October 28, 2019 21:32
-
-
Save ErikBoesen/30c0d5c78e8a2db81d747ac2c8e1f114 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 sort(array): | |
less = [] | |
equal = [] | |
greater = [] | |
if len(array) > 1: | |
pivot = array[0] | |
for x in array: | |
if x < pivot: | |
less.append(x) | |
elif x == pivot: | |
equal.append(x) | |
elif x > pivot: | |
greater.append(x) | |
return sort(less) + equal + sort(greater) | |
else: | |
return array | |
print(sort([4, 66, 3, 5, -20, 0])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment