I need to sort a std::map by value, then by key. The map contains data like the following:
1 realistically
8 really
4 rea
std::map already sorts the values using a predicate you define or std::less if you don't provide one. std::set will also store items in order of the of a define comparator. However neither set nor map allow you to have multiple keys. I would suggest defining a std::map if you want to accomplish this using your data structure alone. You should also realize that std::less for string will sort lexicographically not alphabetically.