template <class RandomAccessIterator, class Compare>
void sort (RandomAccessIterator first, RandomAccessIterator last, Compare comp);
Sorts the elements in the range [first,last) into ascending order.
The elements are compared using comp.
Equivalent elements are not guaranteed to keep their original relative order
Complexity
On average, linearithmic in the distance between first and last: Performs approximately N*log2(N) (where N is this distance) comparisons of elements, and up to that many element swaps (or moves).
It is not stated what sorting algorithm the std::sort does / has to use, but the functor is used approximately N*log2(N) times.
Just to be completely sure I understood the subject properly, we say that sort uses a mixture of algorithms by/called Introsort even if we've supplied the sort predicate with a user-defined functor that just is using the less-than operator?
One side question, what does exist inside the std namespace? Does it only include STL containers and related algorithms?
> Introsort even if we've supplied the sort predicate
The standard sort algorithm is a comparison sort; it compares elements to determine their relative order.
The algorithm uses the predicate to perform the comparisons.
> One side question, what does exist inside the std namespace?
> Does it only include STL containers and related algorithms?