#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef struct example
{
int elem1;
int elem2;
}example;
//这个comparison函数很重要.
//如果希望升序排序,就是"<",降序排列就是">"号
//这样便于直观记忆.如果希望用elem2作为比较标准
//就把elem1改为elem2,这样结构体就以elem2为比较标准排序了
bool comparison(example a,example b){
return a.elem1<b.elem1;
}
sort关键字排序
最新推荐文章于 2021-11-04 07:56:01 发布