Quicksort gets lowest score first instead of highest
#1

The following script makes to lowest score comes first. But i want the highest one to come first. How can i make this possible with the following script?

pawn Code:
stock quickSort(array[], left, right)
{
    new
        tempLeft = left,
        tempRight = right,
        pivot = array[(left + right) / 2],
        tempVar
    ;
    while(tempLeft <= tempRight)
    {
        while(array[tempLeft] < pivot) tempLeft++;
        while(array[tempRight] > pivot) tempRight--;

        if(tempLeft <= tempRight)
        {
            tempVar = array[tempLeft], array[tempLeft] = array[tempRight], array[tempRight] = tempVar;
            tempLeft++, tempRight--;
        }
    }
    if(left < tempRight) quickSort(array, left, tempRight);
    if(tempLeft < right) quickSort(array, tempLeft, right);
}
Reply


Messages In This Thread
Quicksort gets lowest score first instead of highest - by HireMe - 14.12.2012, 21:50
Re: Quicksort gets lowest score first instead of highest - by Vince - 14.12.2012, 21:52
Re: Quicksort gets lowest score first instead of highest - by HireMe - 15.12.2012, 11:37
Re: Quicksort gets lowest score first instead of highest - by Sinner - 15.12.2012, 12:40

Forum Jump:


Users browsing this thread: 1 Guest(s)