/* quicksort_place: * For now, we keep the current implementation for stability, but * we should consider replacing this with an implementation similar to * quicksort_placef above. */ void quicksort_place(double *place, int *ordering, int first, int last) { if (first < last) { int middle; #ifdef __cplusplus split_by_place(place, ordering, first, last, middle); #else split_by_place(place, ordering, first, last, &middle); #endif quicksort_place(place, ordering, first, middle - 1); quicksort_place(place, ordering, middle + 1, last); } }
/* quicksort_place: * For now, we keep the current implementation for stability, but * we should consider replacing this with an implementation similar to * quicksort_placef above. */ void quicksort_place(double *place, int *ordering, int first, int last) { if (first < last) { int middle; #ifdef __cplusplus split_by_place(place, ordering, first, last, middle); #else split_by_place(place, ordering, first, last, &middle); #endif quicksort_place(place, ordering, first, middle - 1); quicksort_place(place, ordering, middle + 1, last); /* Checking for "already sorted" dramatically improves running time * and robustness (against uneven recursion) when not all values are * distinct (thefore we expect emerging chunks of equal values) * it never increased running time even when values were distinct */ if (!sorted_place(place,ordering,first,middle-1)) quicksort_place(place,ordering,first,middle-1); if (!sorted_place(place,ordering,middle+1,last)) quicksort_place(place,ordering,middle+1,last); } }