I'll show you how to change sorting order with comparators. Use sort(v.begin(), v.end(), greater<int>()) for descending order. You can write custom comparators as lambda functions: sort(v.begin(), v.end(), [](int a, int b) { return a > b; }).
This gives you full control over sorting logic. For pairs, you might sort by second element: [](auto a, auto b) { return a.second < b.second; }. The comparator returns true if first argument should come before second.