Logo

Programming-Idioms

History of Idiom 113 > diff from v25 to v26

Edit summary for version 26 by chardan:
New Cpp implementation by user [chardan]

Version 25

2019-09-26, 18:44:10

Version 26

2019-09-27, 21:55:27

Idiom #113 Iterate over map entries, ordered by values

Print each key k with its value x from an associative array mymap, in ascending order of x.
Note that multiple entries may exist for the same value x.

Idiom #113 Iterate over map entries, ordered by values

Print each key k with its value x from an associative array mymap, in ascending order of x.
Note that multiple entries may exist for the same value x.

Extra Keywords
traverse traversal
Extra Keywords
traverse traversal
Code
 for_each(begin(m), end(m),
          [&s](const auto& kv) { s.insert(kv.second); });
Comments bubble
Using a std::multiset<>
Demo URL
https://godbolt.org/z/Tt3IUc