将map中的元素用vector<pair<type1,type2>>的形式存储,利用vector可以自定义排序方式,定义排序操作。
例如:有一个map,其元素为形如name:score的形式,现要求按分数排序。
#include<vector>
#include<map>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
map<string, int> name_scores;