sort()
是<algorithm>中
default (1)
template <class RandomAccessIterator>
void sort (RandomAccessIterator first, RandomAccessIterator last);
custom (2)
template <class RandomAccessIterator, class Compare>
void sort (RandomAccessIterator first, RandomAccessIterator last, Compare comp);
RandomAccessIterator
Compare
:函数,接收2个参数,返回bool值,表明这2个数是否满足顺序
默认的comparison为<,接收1和2,1和2满足"<"的顺序么? 满足,返回true
调用sort()后的序列是有序且顺序的
参考
sort - C++ Reference sort()
的声明
关于C++各类排序算法与std::sort性能的比较 各种排序方法时间比较
linux - What makes the gcc std::list sort implementation so fast? - Stack Overflow
网友评论