Logo

Programming-Idioms

History of Idiom 112 > diff from v19 to v20

Edit summary for version 20 by 1.7.4:
New JS implementation by user [1.7.4]

Version 19

2018-08-29, 18:44:25

Version 20

2019-01-24, 12:38:52

Idiom #112 Iterate over map entries, ordered by keys

Print each key k with its value x from an associative array mymap, in ascending order of k.

Idiom #112 Iterate over map entries, ordered by keys

Print each key k with its value x from an associative array mymap, in ascending order of k.

Extra Keywords
traverse traversal
Extra Keywords
traverse traversal
Code
[...mymap.entries()].sort().map(([_, x]) => console.log(x))
Comments bubble
We have to spread mymap.entries() because it returns an iterator instead of a list.