How can I sort an unordered_map by key? I need to print an unordered_map sorted by key.
unordered_map
std::unordered_map<int, int> unordered; std::map<int, int> ordered(unordered.begin(), unordered.end()); for(auto it = ordered.begin(); it != ordered.end(); ++it) std::cout << it->second;
548k questions
547k answers
4 comments
86.3k users