I tried to use lambda function with sort, but was getting \"Segmentation fault\" errors. I managed to simplify the code to the following:
#inclu
The comparison predicate should return a bool: true if a < b and false otherwise. Change the return statement to:
return a < b;
Not to be confused with C-style 3-way comparison functions.
NOTE: Though C++20 does introduce a 3-way comparison operator <=>, sort would still expect a 2-way compare predicate.