Skip to content

Instantly share code, notes, and snippets.

@samrat
Created July 12, 2011 13:04
Show Gist options
  • Save samrat/1077935 to your computer and use it in GitHub Desktop.
Save samrat/1077935 to your computer and use it in GitHub Desktop.
Crude implementation of Quicksort algorithm in Python.
def quicksort(list):
if len(list) <= 1: return list
pivot = list[0]
great = []
less = []
for item in list[1:]:
if item>=pivot:
great.append(item)
elif item<pivot:
less.append(item)
return quicksort(less)+[pivot]+quicksort(great)
#test
print quicksort([45,99,1,-22,7,3,294,10,36])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment