Sorting the Hash. I seem to have checked everything. What's wrong with my code?


#1

This code gives me this error message:
Oops, try again. It looks like you haven't set the frequencies hash correctly. Check the first exercise if you need help!

What did I do wrong?

puts "Input string please:"
text = gets.chomp

words = text.split(" ")

frequencies = Hash.new(0)
frequencies = words.each {|word| frequencies[word] += 1}
frequencies = frequencies.sort_by {|k, v| v }  
frequencies.reverse!


#2

should just be,

words.each {|word| frequencies[word] += 1}