Skip to content

Instantly share code, notes, and snippets.

@ta1hia
Created May 31, 2016 22:30
Show Gist options
  • Save ta1hia/2320e8b1a02a6c3ec6e82d4a5fa24c88 to your computer and use it in GitHub Desktop.
Save ta1hia/2320e8b1a02a6c3ec6e82d4a5fa24c88 to your computer and use it in GitHub Desktop.
def qsort(A, L, U):
if L < U:
T = A[L]
M = L #pivot
for i in range(L+1, U):
if A[i] < T:
M += 1
tmp = A[M]
A[M] = A[i]
A[i] = tmp
A[L] = A[M]
A[M] = T
qsort(A, L, M)
qsort(A, M+1, U)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment