Skip to content

Instantly share code, notes, and snippets.

@edwardbadboy
Created March 23, 2012 06:14
Show Gist options
  • Save edwardbadboy/2167521 to your computer and use it in GitHub Desktop.
Save edwardbadboy/2167521 to your computer and use it in GitHub Desktop.
useful awk functions
function qsort(A, left, right, i, last) {
if (left >= right)
return
last = left
for (i = left+1; i <= right; i++)
if (A[i] < A[left])
swap(A, ++last, i)
swap(A, left, last)
qsort(A, left, last-1)
qsort(A, last+1, right)
}
function swap(A, i, j, t) {
t = A[i]; A[i] = A[j]; A[j] = t
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment