Skip to content

Instantly share code, notes, and snippets.

@ErikBoesen
Created October 28, 2019 21:32
Show Gist options
  • Save ErikBoesen/30c0d5c78e8a2db81d747ac2c8e1f114 to your computer and use it in GitHub Desktop.
Save ErikBoesen/30c0d5c78e8a2db81d747ac2c8e1f114 to your computer and use it in GitHub Desktop.
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