How to group by the elements of an array in Swift How to group by the elements of an array in Swift swift swift