The partial_sort_copy() algorithm places the smaller of finish - start and result_finish - result_start sorted elements from the range [start, finish) into the range beginning at result_start (in other words, the range: [result_start, result_start+min(finish - start, result_finish - result_start)). The effect is as if the range [start,finish) were placed in a temporary buffer, sorted, and then as many elements as possible copied into the range [result_start, result_finish).

The first version of the algorithm uses operator<() as the comparison operator for the sort. The second version uses the function object comp.