Hi guys, i am currently facing a problem implementing a boolean function inside my sort function.
the story around my program is that i want to sort the values according to a civi index which is stored into the array after i compute it which is in this way.
1 2 3 4 5 6
|
float civiIndex=getData.getCiviIndex();
stringstream convertIndex;
convertIndex<<civiIndex;
string index=convertIndex.str();
dataStore[i]+=index+",";
copy2=dataStore[i];
|
i first convert it into a string then i store it into a string array.
then my logic is to sort it according to the civi index which i tried doing this
sort(dataStore,dataStore+100,greater<string>());
It works but however, it does not sort in the criteria of civi index.
then i tried to implement a boolean function, which is this
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
bool pointTwoD::myFunction(string a ,string b)
{
dataA=a;
dataB=b;
float convertA,convertB;
stringstream(dataA)>>convertA;
stringstream(dataB)>>convertB;
//cout<<convertA;
//cout<<convertB;
return (convertA>convertB);
}
|
which returns me a 0 when i call out the result instead of a true/false.
then another question is how do i implement this function in the sort method.
i tried to do this
sort(dataStore,dataStore+100,myFunction(copy,copy));
it just gives me tons of errors.
May i know what is the correct way of sorting according to civiIndex and also the correct way of implementing and calling the sort function?
Thanks alot in advance. =)