I am having troubles with sort in C++.. Have been trying to get this to work for multiple hours and am getting no where. I do not understand how to actually get the sort algorithm predicate function to work.
Anyway heres an example of what I am trying to do:
Code: Select all
class test {
int a;
int b;
int c;
}
Now I use that class as an object to fill up the a vector. I want to actually sort them by int A but cant figure out the syntax.
Code: Select all
sort ( bleh.begin(), bleh.end(), test);
// Ok - so test would need to be a predicate function
bool test (const test& p1, const test& p2)
{
return p1.a < p2.a;
}
function call missing argument list
Of course it doesnt have an argument list because I dont know that argument as I am trying to sort the vector.
Anyway, I am completely lost here and really could use some help.
Thanks,
trixs