Today I was solving a problem on topcoder in which I have to sort countries by medals in Olympics. I have an STL container vector<pair<vector<int>, string> > v; The vector<int> contains no of gold, silver and bronze won by a country. I have to sort the structure in this particular order gold, silver, bronze and country(alphabetic order).
I used sort(v.begin(), v.end()) but this sorting only by the first value in the pair ie by gold, silver and bronze and its not ordering countries by alphabetic order when g,s,b medals of two countries are same.
You have to provide your comparison functional object.