From: Juan Gf Date: 2010-03-23T18:47:53+09:00 Subject: sort elements Hello, I'm newbie so I apologize if my question it's stupid. I want to write a program that counts how many times a word appears in a text. This is my code: a = 'Apple car caR house tree ice ice ice house' b = a.downcase.split(' ') b.uniq.each do |element| puts "#{b.count(element)}\t#{element}" end But this code produces this: 1 apple 2 car 2 house 1 tree 3 ice and I want something like this: 3 ice 2 car 2 house 1 apple 1 tree Any ideas? -- Posted via http://www.ruby-forum.com/.