Currently I am trying to sort a vector of structs based on a specific field. I have set up a custom comparison function for the use of the sort function. However, i am getti
Although this is an old question, I would like to note for the benefit of the future readers the possibility of directly sorting according to a specific field with the help of projections in the upcoming Ranges library in C++20:
ranges::sort(vecData, ranges::less, &Play::relevance);
This avoids the need of specifying two iterators or writing a custom comparison function or lambda.