Move common sorting to the base grouping component