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]. ???
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);
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With