hey guys,
I need a little help. I have a vector of objects, each object has a name and an age variable. I want to be able to sort the vector by each objects age. Google brings up alot of results but I don't really understand most of them. This is what I've got so far. (might be some syntax mistakes, not a copy and paste job)
Class people{ string name, int age..... }
vector<people> vec;
bool SortMethod (const people& person1, const people& person2) const
{ return person1.getage() < person2.getage(); }
void Sort()
{
(vec.begin(), vec.end(), SortMethod);
}
Now according to all the threads I've read this is how to do it but it doesn't seem to do anything. Little help please. Thanks.


LinkBack URL
About LinkBacks
Reply With Quote

