Hi, I want to customize cmp for std::sort() in some cases. Like to sort Interval. Before I can use code like this:
// before the Solution class, I define cmp
bool cmp (Interval& lhs, Interval& rhs) {
// I want to sort based on the start of Interval, and then the length of Interval
return lhs.start<rhs.start || (lhs.start==rhs.start && (lhs.end-lhs.start)<=(rhs.end-rhs.start));
}
// in Solution class, I just need to use
std::sort(intervals.begin(),intervals.end(),cmp);This code works fine before, but has runtime error since several days ago.
My question: any idea how to define a custom cmp without runtime error in current environment?