How can I implement STL map sorting by value?
For example, I have a map m:
m
map m; m[1] = 10; m[2] = 5; m[4] = 6; m[6] =
You can build a second map, with the first map's values as keys and the first map's keys as values.
This works only if all values are distinct. If you cannot assume this, then you need to build a multimap instead of a map.