// quickSort // // This public-domain C implementation by Darel Rex Finley. // // Modified by Giuseppe Gatta #include #include #include void qsort(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *)) { #define QSORT_MAX_LEVELS 300 int beg[QSORT_MAX_LEVELS], end[QSORT_MAX_LEVELS], i=0, L, R, swap ; char piv[size]; beg[0]=0; end[0]=nmemb; while (i>=0) { L=beg[i]; R=end[i]-1; if (L 0 && Lend[i-1]-beg[i-1]) { swap=beg[i]; beg[i]=beg[i-1]; beg[i-1]=swap; swap=end[i]; end[i]=end[i-1]; end[i-1]=swap; } } else { i--; } } }