stable_sort定义
template
void stable_sort ( RandomAccessIterator first, RandomAccessIterator last );
template
void stable_sort ( RandomAccessIterator first, RandomAccessIterator last,
Compare comp );
第三个参数comp
: 它是一个二元函数,返回一个bool
值。他决定了第一个元素是否在第二个前面,简单来说,如果返回true
顺序就是参数顺序,反之,则是参数反序。 Binary function that accepts two elements in the range as arguments, and returns a value convertible to bool. The value returned indicates whether the element passed as first argument is considered to go before the second in the specific strict weak ordering it defines. The function shall not modify any of its arguments. This can either be a function pointer or a function object.
#include
#include
#include
#include
using namespace std;
struct student
{
student(string name ,int id,double stature):m_name(name),m_id(id),m_stature(stature){}
string m_name; //名字
int m_id; //学号
double m_stature; //身高
};
//student对象从高到低排列
bool comp(student s1, student s2)
{
return s2.m_stature
关注
打赏
最近更新
- 深拷贝和浅拷贝的区别(重点)
- 【Vue】走进Vue框架世界
- 【云服务器】项目部署—搭建网站—vue电商后台管理系统
- 【React介绍】 一文带你深入React
- 【React】React组件实例的三大属性之state,props,refs(你学废了吗)
- 【脚手架VueCLI】从零开始,创建一个VUE项目
- 【React】深入理解React组件生命周期----图文详解(含代码)
- 【React】DOM的Diffing算法是什么?以及DOM中key的作用----经典面试题
- 【React】1_使用React脚手架创建项目步骤--------详解(含项目结构说明)
- 【React】2_如何使用react脚手架写一个简单的页面?