Another option instead of partial_sort with reverse iterators and std :: is more for comparison - use std::nth_element to separate the collection, then std :: sort to sort the section you are interested in:
std::vector<int> data{5, 2, 1, 6, 4, 8, 10}; // your data, shuffled std::nth_element(data.begin(), data.begin()+2, data.end()); std::sort(data.begin()+2, data.end();
source share