Standard C++ Library Reference ISO/IEC (VERSION3)

template<class BidIt, class Pr>
bool next_permutation(BidIt first, BidIt last,
Pr pred);
The first template function determines a repeating sequence of permutations, whose initial
permutation occurs when the sequence designated by iterators in the range [first, last) is
ordered by operator<. (The elements are sorted in ascending order.) It then reorders the
elements in the sequence, by evaluating swap(X, Y) for the elements X and Y zero or more
times, to form the next permutation. The function returns true only if the resulting sequence is
not the initial permutation. Otherwise, the resultant sequence is the one next larger
lexicographically than the original sequence. No two elements may have equivalent ordering.
The function evaluates swap(X, Y) at most (last - first) / 2.
The second template function behaves the same, except that it replaces operator<(X, Y)
with pred(X, Y).
nth_element
template<class RanIt>
void nth_element(RanIt first, RanIt nth, RanIt last);
template<class RanIt, class Pr>
void nth_element(RanIt first, RanIt nth, RanIt last,
Pr pred);
The first template function reorders the sequence designated by iterators in the range [first,
last) such that for each N in the range [0, nth - first) and for each M in the range
[nth - first, last - first) the predicate !(*(first + M) < *(first +
N)) is true. Moreover, for N equal to nth - first and for each M in the range (nth -
first, last - first) the predicate !(*(first + M) < *(first + N)) is true.
Thus, if nth != last the element *nth is in its proper position if elements of the entire
sequence were sorted in ascending order, ordered by operator<. Any elements before this one
belong before it in the sort sequence, and any elements after it belong after it.
The function evaluates the ordering predicate X < Y a number of times proportional to last -
first, on average.
The second template function behaves the same, except that it replaces operator<(X, Y)
with pred(X, Y).
partial_sort
template<class RanIt>
void partial_sort(RanIt first, RanIt mid,
RanIt last);
template<class RanIt, class Pr>