cpp/algorithm/partial sort copy

Sorts some of the elements in the range in ascending order, storing the result in the range.

At most of the elements are placed sorted to the range. is the number of elements to sort. The order of equal elements is not guaranteed to be preserved.

@1@ Elements are compared using. @3@ Elements are compared using the given binary comparison function. @2,4@ Same as, but executed according to.

Return value
An iterator to the element defining the upper boundary of the sorted range, i.e..

Complexity
$O(N&middot;log(min(D,N))$, where, applications of.

Possible implementation
See also the implementations in libstdc++ and libc++.