By definition you cannot sort a std::map by value, since a std::map sorts its elements by key.
This posting documents a way to get around this by dumping std::map key-value pairs into a std::vector first, then sorting that std::vector with a less-than functor afterwards
(more…)