What is the complexity of std::sort()
in the C++ Standard Library? Which sort is applied? Is there any rule of applying any particular sorting algorithm there?<
If you mean std::sort()
:
This is from C++03 standard, section 25.3. The performance guarantee:
template
void sort(RandomAccessIterator first, RandomAccessIterator last);
template void sort(RandomAccessIterator first, RandomAccessIterator last,
Compare comp);
1 Effects: Sorts the elements in the range [first, last).
2 Complexity: Approximately N log N (where N == last - first) comparisons on the average.