I am using a map in the standard way. It holds keys and values and sorts them by key and works wonderfully. However, after I am through adding to the map, I need to rank the keys based on their associated values. What is the best solution?
A) Take map<myKey, myValue> object and copy by value each element into a multi-map, but reverse the order so that it looks like multimap<myValue,myKey>. This will sort the by the values from the old map object which will now be keys in the multi-map.
B) Create a struct that holds both myKey and myValue
struct myPairs
{
myKey k;
myValue v;
};
and then push_back those objects into a vector for sorting?
C) The same as B, but use pointers. Don't have to copy by value so should be faster
D) Use a container tool from Boost or some other library that I'm not familiar with that works like map, but allows sorting by value.