Original Post
Hi I got a problem to use a custom function together with std::sort. I tried this: But the AlternativeComp seams to have the wrong format. What is the correct one?
struct wordElement
{
int fileIndex;
string word;
bool unique;
bool operator < (const wordElement& comp) const
{
return word < comp.word;
};
};
bool AlternativeComp( wordElement comp0, wordElement comp1)
{
return comp0.fileIndex < comp1.fileIndex;
}
sort( allWordsSet.begin(), allWordsSet.end(), AlternativeComp);