sorting vectors based on size()

c++, sorting, vector

Solution

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);

Problem

i have a 2-d vector like `vector < vector < coordinates > > v( points);` where coordinates class is: ``` class coordinate{ public : int x; int y; coordinate(){ x=0; y=0; } }; ``` and points is 20. how to sort the individual vectors v[i] based on v[i].size() , ie based on number of coordinates objects pushed in v[i]. ???

Original source