Logo

Programming-Idioms

History of Idiom 112 > diff from v10 to v11

Edit summary for version 11 by :
New Ruby implementation by user [steenslag]

Version 10

2016-02-18, 16:58:03

Version 11

2016-04-06, 20:59:45

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.

Code
my_map.sort.each{|k,x| puts "#{k}: #{x}"}