Sorting a vector of custom objects

后端 未结 13 2933
既然无缘
既然无缘 2020-11-21 05:14

How does one go about sorting a vector containing custom (i.e. user defined) objects.
Probably, standard STL algorithm sort along with a predicate (a fu

13条回答
  •  渐次进展
    2020-11-21 05:55

    You can use user defined comparator class.

    class comparator
    {
        int x;
        bool operator()( const comparator &m,  const comparator &n )
        { 
           return m.x

提交回复
热议问题