-
-
Save jhyland87/469ca8d6ca7498f6d0ed35aedf0a1521 to your computer and use it in GitHub Desktop.
useful awk functions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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