Fix compareTo in writeGroup