If the values in a container have certain operators already overloaded, std::sort can be used with specialized functors to sort in either ascending or descending order:
C++11
#include <vector>
#include <algorithm>
#include <functional>
std::vector<int> v = {5,1,2,4,3};...