In C++17 you can do this:
#include <iostream>
#include <algorithm>
#include <functional>
int main()
{
double values[5] = { 1.1, 2.2, 3.3, 4.4, 5.5 };
// Notice this:
std::sort(values, values+5, std::greater());
for(double v: values) std::cout << v << " ";
std::cout << "\n";
}
Run Code Online (Sandbox Code Playgroud)
You don't actually need to specify the template parameter of std::greater.
It will be automatically deduced as double. That's really nice.
But wait... How?!?
There's nothing telling std::greater that the template parameter should be …