I need to find nth largest element in an array and currently I'm doing it the following way:
std::vector<double> buffer(sequence); // sequence is const std::vector<double>
std::nth_element(buffer.begin(), buffer.begin() + idx, buffer.end(), std::greater<double>());
nth_element = buffer[idx];
But is there any way to find the n-th largest element in an array without using an external buffer?