After doing some research I have resigned to ask what is going wrong with std::sort
.
Following Oliver Charlesworth advice from here I created a comparative, included the algorithm header and called std::sort
in my function. I am still getting errors. Probably an oversight but still.
Errors:
Error C2780 void std::sort(_RanIt,_RanIt)': expects 2 arguments - 3 provided
Error C2672 'std::sort': no matching overloaded function found
Error C3867 'ImageEvaluator::comparator': non-standard syntax; use '&' to create a pointer to member
Struct:
struct numLocWidth
{
int width;
int number;
int location;
};
Comparative:
bool comparator(const numLocWidth &a, const numLocWidth &b)
{
return a.location < b.location;
}
Function:
if (tempMax > minAcceptableValue)
{
tempLocAndVal.location = max_Pot_Loc.x;
tempLocAndVal.number = i - 1;
tempLocAndVal.width = templates[7][i].size().width;
foundNumbers.push_back(tempLocAndVal);
std::sort(foundNumbers.begin(), foundNumbers.end(), comparator);
}
Not sure what is going on here and have been scratching my head for a bit. I could write my own sort function but I'm pretty sure this way will be more efficient.