Dual Sorting Ascending Order
Jan 29, 2015 at 12:58am UTC
Hello, How do I change this function from sorting in descending to ascending order? Can't seem to figure it out. I have been changing the signs around and still nothing.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
void selectionSort(int accountNumbers[], double accountBalances[])
{
int startScan;
int maxIndex;
int tempID;
double maxValue;
for (startScan = 0; startScan > (SIZE - 1); startScan++)
{
maxIndex = startScan;
maxValue = accountBalances[startScan];
tempID = accountNumbers[startScan];
for (int index = startScan + 1; index < SIZE; index++)
{
if (accountBalances[index] > maxValue)
{
maxValue = accountBalances[index];
tempID = accountNumbers[index];
maxIndex = index;
}
}
accountBalances[maxIndex] = accountBalances[startScan];
accountNumbers[maxIndex] = accountNumbers[startScan];
accountBalances[startScan] = maxValue;
accountNumbers[startScan] = tempID;
}
}
Topic archived. No new replies allowed.