By default, sets and maps use the < operator for ordering. You can change this: set<int, greater> s; stores elements in descending order instead of ascending. For custom types, define a struct with bool operator()(T a, T b) that returns true if a should come before b.
Pass this struct as the second template argument to set or map. Lambdas work but require more verbose syntax. For simple reversals, greater from the header is the easiest option.
Include it and specify as the comparator.