0

I have searched online for a while, but I still cannot figure out how the following one-line comparator works. I know inside the () are the parameters, but where is the return type bool? Is the name of the function omitted? What's the purpose of []?

/**
 * Definition for an interval.
 * struct Interval {
 *     int start;
 *     int end;
 *     Interval() : start(0), end(0) {}
 *     Interval(int s, int e) : start(s), end(e) {}
 * };
 */
sort(intervals.begin(), intervals.end(), [](Interval& a, Interval& b){return a.start < b.start;});
hellow
  • 10,920
  • 6
  • 47
  • 69
Lusha Li
  • 908
  • 2
  • 8
  • 20

0 Answers0