c++ - How will the sorting be done with vector<pair<int,pair<int,int>>>? -
in code sort(a.begin(),a.end()); a defined vector<pair<int,pair<int,int>>> a;.
if call sort method, on basis sorting done?
it compare using operator < std::pair, specified here.
it compares elements lexicographically on first element first, , if equal, on second element.
given complex type here pair<int,pair<int,int>>, may better idea give std::sort algorithm custom comparator. make sure functor provided fulfils requirements of compare concept, being strict weak ordering.
Comments
Post a Comment