I have created a very ugly script to collect same numbers from an array. I don\'t think this is a very Ruby way :) Anyone could provide a more clean solution?
ar
In case if you want to do it without order:
ar.group_by(&:itself).values => [[5, 5], [2, 2, 2], [6, 6]]