fix ordering and grouping for the repeating fields