i has a 2nd vector, such as vector < vector < coordinates > > v( points);where the class of coordinates:
vector < vector < coordinates > > v( points);
class coordinate{ public : int x; int y; coordinate(){ x=0; y=0; } };
and the points are 20. how to sort individual vectors v [i] based on v [i] .size (), that is, based on the number of coordinate objects inserted in v [i]. ???
1) make a function that compares two vectors based on size:
bool less_vectors(const vector& a,const vector& b) { return a.size() < b.size(); }
2) sort with it
sort(v.begin(),v.end(),less_vectors);
create a function in which you can use any attributes to compare objects, and then use the STL sorting algorithm to sort the container.
< , . sort(), STL (, STL).