
26 Nov
2005
26 Nov
'05
2:03 p.m.
Hi! Sumanth J.V wrote:
Now my code compiles. However, I would like to change the default behavior of the comparison operator. From the boost documentation, "the operators <, >, <= and >= implement a lexicographical ordering". But I would like comparison to be based only on the second element of the tuple. Is there anyway this can be implemented?
To this end, you may supply a custom comparison operator to std::sort. struct my_compare_op { bool operator()(const Task& a, const Task& b) const { return boost::get<1>(a) < boost::get<1>(b); } }; and then, std::sort(ts.begin(), ts.end(), my_compare_op()); HTH, João Abecasis