This is a standard recursive quickSort implementation, and it succeeds at sorting larger lists for unsorted items but not for "pre-sorted" items. I knew it would take longer, but not fail altogether. Any possible improvements?
void quickSort(int *array, size_t count) {
int pivot = array[count - 1];
int max_index = 0;
for (size_t i = 0; i < count - 1; ++i)
{
if (array[i] < pivot) {
swap(array[i], array[max_index]);
++max_index;
}
}
swap(array[max_index], array[count - 1]);
if (max_index > 1)
quickSort(array, max_index);
if (count - max_index - 1 > 1)
quickSort(array + max_index + 1, count - max_index - 1);
}