Sort goals properly so they don't clobber each others' groups