2000-05-09から1日間の記事一覧
キーでソートする h = Hash[*%w[Apple red Banana yellow Lemon yellow Carrot orange Grape purple]] a = h.keys.sort # キーを配列にしてソートする p a #=> ["Apple", "Banana", "Carrot", "Grape", "Lemon"] a.each{|x| p "#{x} is #{h[x]}"} #=> "Apple…
キーでソートする h = Hash[*%w[Apple red Banana yellow Lemon yellow Carrot orange Grape purple]] a = h.keys.sort # キーを配列にしてソートする p a #=> ["Apple", "Banana", "Carrot", "Grape", "Lemon"] a.each{|x| p "#{x} is #{h[x]}"} #=> "Apple…