Doubt in probelm

How can we sort hash map by value ?

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];
}