int partition(int theList[], int start, int end)
{ int pivot = theList[end];
int bottom = start-1;
int top = end;
bool notdone = true;
while (notdone)
{
while (notdone)
{
bottom += 1;
if (bottom == top)
{
notdone = false;
break;
}
if (theList[bottom] > pivot)
{
theList[top] = theList[bottom];
break;
}
}
while (notdone)
{
top = top-1;
if (top == bottom)
{
notdone = false;
break;
}
if (theList[top] < pivot)
{
theList[bottom] = theList[top];
break;
}
}
}
theList[top] = pivot;
return top;
}//Actual function call within program
int quickSort(int theList[], int start, int end)
{ if (start < end)
{
int split = partition(theList, start, end); //recursion
quickSort(theList, start, split-1);
quickSort(theList, split+1, end);
}
else
{
return 0;
}
}