Can someone point out what i did wrong here?


This is what i put down.
puts "input here"
text = gets.chomp

words = text.split(",")
frequencies =

words.each do |x|
frequencies = frequencies.sort_by {|word, count| count}

frequencies.each { |name , count| puts name + " " + count.to_s }


When we split a string, the array already has comma separators. The split() method needs us to specify what character to split on. Being as we are a handing in a sentence, the separators are spaces.

words = text.split(" ")

You may have discovered and fixed this already...


should follow those two lines, The other two are meant to be outside of the method.