I have a Ruby array
> list = Request.find_all_by_artist(\"Metallica\").map(&:song) => [\"Nothing else Matters\", \"Enter sandman\", \"Enter Sandman
Late but clean answer I have,
l = list.group_by(&:titleize) l.merge(l) { |k,v| l[k] = v.count }
Note: If we do want unique keys i.e. without titleize, then replace it with itself
titleize
itself