sort函数

sort默认从小到大排序
添加标准比较函数
less<数据类型>()//从小到大排
greater<数据类型>()//从大到小排序

字符串比较

"b" > "a"
"abcd" > "abc"
"abc" > "aac"

使用lamda表达式来完成比较函数
https://www.cnblogs.com/jimodetiantang/p/9016826.html

vector> reconstructQueue(vector>& people) {
        sort(people.begin(), people.end(), [](const vector& u, const vector& v) {
            return u[0] > v[0] || (u[0] == v[0] && u[1] < v[1]);
        });

比较函数的写法
https://blog.csdn.net/maverick1990/article/details/37738601

你可能感兴趣的:(sort函数)