How does one go about sorting a vector containing custom (i.e. user defined) objects.
Probably, standard STL algorithm sort along with a predicate (a fu
To sort a vector you can use the sort() algorithm in .
sort(vec.begin(),vec.end(),less());
The third parameter used can be greater or less or any function or object can also be used. However the default operator is < if you leave third parameter empty.
// using function as comp
std::sort (myvector.begin()+4, myvector.end(), myfunction);
bool myfunction (int i,int j) { return (i