Glossary: Data Structures and Algorithms in C++
std::partial_sort
Also written: partial_sort
Puts only the first k items by a comparator at the front, in order, and leaves the rest unsorted. It costs O(n log k), so it's a quick way to get the top few.