STL降序排map

#include <iostream>
#include <map>

using namespace std;

map<int, int, greater<int> > tmp;

int main(void) {
    
    return 0;
}

代码二,伪函数Solution:

#include <iostream>
#include <map>

using namespace std;

template <class T>
struct cmp {
    bool operator () (const T &a, const T &b) const {
        return a > b;
    }
};

map<int, int, cmp<int> > tmp;

int main(void) {
    tmp[1] = 1;
    tmp[2] = 1;
    tmp[3] = 1;
    for (auto x : tmp) {
        cout << x.first << endl;
    }
    return 0;
}