my code is below
puts "input the text : "
text = gets.chomp
words = text.split(" ")
frequencies = Hash.new(0)
words.each do |word|
frequencies[word] += 1
frequencies = frequencies.sort_by do |word, frequency|
Here i have a question. I heard that ruby is object oriented language. Then i think i can sort the Hash without substitution operator, like
frequencies.sort_by do |word, frequency|
I think Hash is also object, therefore it has the "sort_by" method and I think it should work without substitution operator. But.... It's not work.
Is there anybody to help me understanding?