I have an STL map that has String keys and int values. I need to put the items into a new map with int keys and String values, such that the keys are sorted from lowest to greatest.
For example I have a map with these values(key, value):
"A", 5
"B", 2
"C", 8
"D", 4
I would like them to then be arranged in such a way that they look like this(key, value):
2, "B"
4, "D"
5, "A"
8, "C"
Where the value from the original map becomes the key, and the key becomes the value.
I know that I need to add the values from the original map to a new map, but I'm not sure how I would add them in a way that they're sorted from lowest to greatest.