#include "qsort.h" #include "swap.h" /** * new_qsort: sort v[left]...v[right] into increasing order using * comp to compare strings. Based on code from Kernighan and * Ritchie. * Note: Renamed to avoid conflict with qsort in stlib.h. */ void new_qsort (char *v[], int left, int right, int (*comp)(const char *s1, const char *s2), char *separator, int column) { int i, last; int start1, int end1; // Start and end of column from s1 int start2, int end2; // Start and end of column from s2 char save1; // char save2; /* If the array contains fewer than two elements, do nothing. */ if (left >= right) return; swap(v, left, (left + right)/2); last = left; for (i = left+1; i <= right; i++) if ((*comp)(v[i], v[left]) < 0) swap(v, ++last, i); swap(v, left, last); new_qsort (v, left, last-1, comp); new_qsort (v, last+1, right, comp); } // new_qsort