Go back to Richel Bilderbeek's homepage.
Go back to Richel Bilderbeek's C++ page.
std::nth_element is an STL sorting algorithm that sorts a container up until the nth element and leaves the rest unsorted.
The example below shows how to obtain the top-three lowest elements.
#include <algorithm> |
Go back to Richel Bilderbeek's C++ page.
Go back to Richel Bilderbeek's homepage.