generalize groupBy to return Seq and not Map