<algorithm>的排序用法

来源:互联网 发布:ubuntu杀死进程命令 编辑:程序博客网 时间:2024/06/02 06:28

algorithm的排序用法

1、sort函数的时间复杂度为n*log2(n),执行效率较高。
2、sort函数的形式为sort(first,end,method),其中第三个参数可选。
3、若为两个参数,则sort的排序默认是从小到大
4、若需要从大到小排序,则应添加函数method,如
sort(first,end,method);
bool method(int a,int b)
{
return a>b);
}