I can't figure out how to get the sort selection working. I have to sort the scores (doubles) from the struct in ascending order.
Here is my code, I will comment where i am getting the errors.
My struct:
struct diveInfo
{
string diversName;
double totalScore;
double totalScore;
double diff;
double scores[NUM_SCORES];
};
My function to sort the scores in ascending order:
void selectionSort(diveInfo *ptr, int size)
{
diveInfo temp;
double minValue;
int startScan;
int minIndex;
for ( startScan = 0; startScan < (size - 1); startScan++)
{
minIndex = startScan;
minValue = ptr[startScan].scores; //keep getting an error here saying type double cannot be assigned to an entity of type double.
temp = ptr[startScan];
for (int index = startScan + 1; index < size; index++)
{
if ( ptr[index].scores < minValue)
{
temp = ptr[index];
minIndex = index;
}
}
ptr[minIndex] = ptr[startScan];
ptr[startScan] = temp;
}
}