的排序用法

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);
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章