I would like to sort a std::list<std::pair<string, int>> by the key as well as by the value in two separate functions.
I am getting an error that says:
error: reference to non-static member function must be called
sort(test.begin(), test.end(), sortByVal);
The code
class Test
{
std::list<pair<std::string, int>> test;
public:
void sortbykey()
{
sort(test.begin(), test.end(), sortByVal);
}
bool sortByVal(const std::pair<std::string, int>& a, const std::pair<std::string, int>& b)
{
return (a.first < b.first);
}
};