Scala has a function groupBy on lists that accepts a function for extracting keys from list items, and returns another list where the items are tuples consisting of
groupBy
This isn't a function in the List library.
You can write it as the composition of sortBy and groupBy.