Implemented CoordinatesGroups to encapsulate the logic for adding
coordinates to groups, merging groups and sorting groups