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

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -