How to sort boost::unordered_map by value and return only keys in that order ?
I have map like boost::unordered_map and I need I need ony list of enums sorted by int values in asc/desc.
How to sort boost::unordered_map by value and return only keys in that order ?
Share
An
unordered_mapis, as the name implies, inherently not sorted or sortable in-place. You could insert the value pairs into asetthat is sorted on the value and get the keys from there (using Boost.Range to make this stuff easier). I use astd::set<T*>to not pay the cost of copying the pair objects.Live example.