I would probably restructure the data with group_by so that it more or less matches the desired result. Then you can print the date once since it becomes the key in the hash, and then an array of impressions for that date:
shows.group_by(&:date).each do |date, date_shows| puts date puts date_shows end
(I use the default IRB behavior to pass arrays as arguments to puts , where each element is printed on a new line. You can skip this array if you need to do something with them). A.
source share