langs = %w[ java perl python ruby ]groups = langs.group_by {|lang| lang[0] }p groups # => {"j"=>["java"], "p"=>["perl", "python"], "r"=>["ruby"]}