How to compare keys and arrange them on the basis of their values

how to compare keys and arrange them on the basis of their values

form a map<int,int> m; and form a mycompare function to arrange the keys according to value

bool mycompare(int a , int b) { 
      return m[a] < m[b];
}