Sorting the Hash problem, need some help please


#1



https://www.codecademy.com/en/courses/ruby-beginner-en-693PD/0/6?curriculum_id=5059f8619189a5000201fbcb#


Oops, try again. It looks like you haven't set the frequencies hash correctly. Check the first exercise if you need help!


puts "text from the user"
text= gets.chomp

words= text.split(" ")

frequencies= Hash.new[0]
words.each { |word| frequencies[word] += 1 }
frequencies= frequencies.sort_by {|x,  y| y }
frequencies.reverse!


#2

Make sure you're creating the Hash with the correct syntax.

If you go back to "4. Creating the Frequencies Hash", you should notice a difference between what you did there to create the Hash and what you're doing here.


#3

Thanks , found it :stuck_out_tongue:


#4

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