利用multiset对结构体进行排序
#include <bits/stdc++.h>
using namespace std;
struct Person{
int x,y;
};
struct cmp{
bool operator()(Person a,Person b){
return a.x < b.x; //进行从小到大进行排序列
}
};
int main(){
multiset<Person,cmp>v; //定义的时候表示用cmp进行排序
int N = 10;
for(int i = 0; i < N; i++){
v.insert({i,i+1});
}
for(auto i = v.begin(); i != v.end(); i++){
cout<<(*i).x<<ends<<(*i).y<<endl;
}
}