+ 5
Stable sorts preserve the physical order of semantically equivalent values.
std::sort:
The order of equal elements is not guaranteed to be preserved.
Complexity: O(N·log(N)), where N = std::distance(first, last) comparisons
std::stable_sort:
The order of equal elements is guaranteed to be preserved.
Complexity: O(N·log^2(N)), where N = std::distance(first, last) applications of cmp. If additional memory is available, then the complexity is O(N·log(N)).
The implication is that std::stable_sort cannot be performed quite as efficiently in terms of execution time, unless "additional memory is available" in which case it is not being performed as efficiently in terms of memory consumption.
Sort elements of heap
Sorts the elements in the heap range [first,last) into ascending order.
The elements are compared using operator< for the first version, and comp for the second, which shall be the same as used to construct the heap.
The range loses its properties as a heap.