Sort a Vector of Objects

  1. Since you have successfully implemented the function loginCount(), you are further requested to sort the vector before it is returned.
  2. You should sort the records by their login counts, in descending order.
  3. If you want to utilize the sort algorithm provided by STL, you may need to define your own comparison function to determine the precedence of CCount objects. For example,
    bool greaterThan(const CCount& a, const CCount& b) {
        return a.count > b.count;
    }
  4. Or, a even simpler solution is to utlize the template greater<CCount>(). You may be required to declare your openrator>() as const.
  5. The output may look like:
    solomon 133
    s110321018 89
    s110321063 77
    s107321058 60
    s110321041 58
    s109352001 54
    s110321012 54
    s107214005 54
    s110321021 50
    s109321066 50