Loop the Loop with Loop


#1

puts "Text please: "
text = gets.chomp

words = text.split(" ")
frequencies = Hash.new(0)
words.each { |word| frequencies[word] += 1 } #stuck on this line
frequencies = frequencies.sort_by {|a, b| } #to
frequencies.reverse!
frequencies.each { |word, frequency| puts word + " " + frequency.to_s } #end


#2

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.