See the Pen Custom grouping function by christianacca (@christianacca) on CodePen.