Compiler complains on the third parameter of the library function sort [duplicate]

  c++
bool compare(vector<int> &i1, vector<int> &i2)
    {
        return (i1[0] < i2[0]);
    }
vector<vector<int>> &intervals = {{1,3},{2,6},{8,10},{15,18}}; 
sort(intervals.begin(), intervals.end(), compare);

What I want to do is sorting intervals based on the start time. But when I run the codes, the compiler will complain on the function sort that "error: reference to non-static member function must be called" Could anyone explain why it doesn’t work?

Source: Windows Questions C++

LEAVE A COMMENT