Skip to content

Instantly share code, notes, and snippets.

@gennad
Created May 29, 2011 16:22
Show Gist options
  • Save gennad/997907 to your computer and use it in GitHub Desktop.
Save gennad/997907 to your computer and use it in GitHub Desktop.
Quikcosrt Python
#Three-way QuickSort in Python
def quicksort(a):
if len(a) == 0:
return []
p = a[(len(a)-1)//2]
less = quicksort([x for x in a if x < p])
greater = quicksort([x for x in a if x > p])
equal = [x for x in a if x == p]
return less + equal + greater
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment