Possible Duplicate:
Ruby Hash with Duplicate Keys?
I defined a hash:
sorted_words = Hash.new(0)
words.each { |word| sorted_words[word]=word.downcase.chars.sort{ |a, b| a.casecmp(b) }.join
Hash does not allow the duplicate keys so if I have keys like cream
, scream
, scream
, it only considers the first two. But I want to also have the third key saved in my Hash with its appropriate value.
This is for an anagram. After the above code I create another hash and, depending on my values from the code, I create multiple arrays with each array having the anagram string.
What could be a solution for such a situation?