Boost provides a map with random-access iterators, so you can std::sort it:
#include <boost/container/flat_map.hpp>
#include <algorithm>
std::sort(your_map.begin(), your_map.end(),
[](const auto& a, const auto& b) {
return a.second != b.second? a.second < b.second : a.first < b.first;
});