I have
a = [\"a\", \"d\", \"c\", \"b\", \"b\", \"c\", \"c\"]
and need to print something like (sorted descending by number of occurrences)
This will give you a hash with element => occurrences:
element => occurrences
b.reduce(Hash.new(0)) do |hash, element| hash[element] += 1 hash end