I'm having some problems using the std sort function. I want to sort a vector of vector without using always the same index. I know I can use something like:
sort(dataset.begin(), dataset.end(), myfunction);
// or
std::sort(dataset.begin(), dataset.end(),
[](const std::vector<int>& a, const std::vector<int>& b) {
return a[2] < b[2]);
});
In the first case I don't know how to include the specified index as an input of myfunction.
In the second case, I though of including the index as an input of the function signature but I can't even make it compile as shown above!
The error:
main.cpp:28:39: error: expected expression sort(dataset.begin(), dataset.end(), [](const vector& a, const vector& b)