Answers for "c++ sort vector of objects by property"

0

c++ sort vector of objects by property

class cat {
public:
    int age;
    bool operator< (const cat &other) const {
        return age < other.age;
    }
};
Posted by: Guest on May-01-2020
0

c++ sort vector of objects by property

vector< cat > catSorter::SortCatsByAge(){
   vector< cat > cats_copy = cats;
   std::sort(cats_copy.begin(), cats_copy.end());
   return cats_copy;
}
Posted by: Guest on May-01-2020

Code answers related to "c++ sort vector of objects by property"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language