#include #include #include #include #include "Person.h" using namespace std; /* static bool comp(const Person &p1, const Person &p2) { return p1.getAge() < p2.getAge(); } */ static void printOut(const vector &vp) { cout << "["; vector::const_iterator iter = vp.begin();; while (iter != vp.end()) { cout << "(" << iter->getName() << "," << iter->getAge() << ")"; if (++iter != vp.end()) cout << ", "; } cout << "]" << endl; } int main(int argc, char **argv) { vector vp; vp.push_back(Person("Johnny Yan", 30)); vp.push_back(Person("James Okada", 21)); vp.push_back(Person("Andrew Davies", 22)); vp.push_back(Person("Renshu Gu", 24)); vp.push_back(Person("John Zohorjan", 45)); cout << "Before sorting:" << endl; cout << " "; printOut(vp); //sort(vp.begin(), vp.end(), comp); sort(vp.begin(), vp.end()); cout << "After sorting:" << endl; cout << " "; printOut(vp); return EXIT_SUCCESS; }