同じ単語を数える 変数で正規表現
テキストファイルを読み取って同じ単語をカウントする
count = Hash.new(0) filename = ARGV[0] file = open(filename) while anything = file.gets something = anything.split something.each do |things| count[things] += 1 end end file.close ## 結果の出力 count.sort{|a,b| a[1] <=> b[1] }.each{|key, value| print "#{key}: #{value}\n" }