Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to groupBy using multiple columns in scala collections

records.groupBy(_.column1)

What if I want to include more columns like if I want to group by column1, column2 and column3?

Any hints?

like image 258
krisp Avatar asked Jul 17 '15 04:07

krisp


1 Answers

Try

records.groupBy(record => (record.column1, record.column2, record.column3))

This will group by a tuple composed of those 3 columns.

like image 146
Ren Avatar answered Oct 02 '22 13:10

Ren