Skip to content

Instantly share code, notes, and snippets.

@saxbophone
Created August 6, 2015 16:41
Show Gist options
  • Select an option

  • Save saxbophone/acf4a9ef9061dab85500 to your computer and use it in GitHub Desktop.

Select an option

Save saxbophone/acf4a9ef9061dab85500 to your computer and use it in GitHub Desktop.
Python Recursive Sort
def sort(unsorted, asc=True):
if len(unsorted) == 1:
return [unsorted[0]]
else:
smallest = 0
for i in range(len(unsorted)):
if unsorted[i] > smallest:
smallest = unsorted[i]
unsorted.remove(smallest)
if asc:
return sort(unsorted) + [smallest]
else:
return [smallest] + sort(unsorted, asc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment