unordered
containers store internally hashed data and thus it's not possible to order them after the hash has been generated.
In order to sort the data you can use an additional non-hashed container (e.g. map or set) and either use them along with the unordered version (so you can use the normal one to sort the data and the unordered one to have fast per-item access) or you can do something like
std::map<int, int> ordered(unordered.begin(), unordered.end());
for(auto it = ordered.begin(); it != ordered.end(); ++it)
std::cout << it->second;
I recommend not to do the above often (unordered containers have slow sequential access)
https://stackoverflow.com/a/6212709/1938163
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…