Creating a sorted hash counting the occurrences of a number in an array
Not sure which viewpoint this would be, but this is what I came up with:

Hash[a.group_by {|e| e}.map {|k,v| [k, v.length]}]


Update: I'm not thrilled with this, but this one sorts by the occurrence count, descending.

Hash[a.group_by {|e| e}.map {|k,v| [k, v.length]}.sort_by {|a| a[1]}.reverse]