Initial implemetantion for groupBy.