MappingGroupComparator implements Comparator<SnomedConcept> { public int compare(final SnomedConcept o1, final SnomedConcept o2) { if (o1 == o2) return 0; if (o1 != null) { if (o2 == null) return 1; else if (o1.mappingGroup.length() != o2.mappingGroup.length()) { return ((Integer)o1.mappingGroup.length()).compareTo(o2.mappingGroup.length()); } else return o1.mappingGroup.compareTo(o2.mappingGroup); } return -1; }  int compare(final SnomedConcept o1, final SnomedConcept o2);  }
@Test public void testCompare() throws Exception { final List<SnomedConcept> sorted = new ArrayList<>(TestData.TEST_DATA); Collections.sort(sorted, new MappingGroupComparator()); for (int i = 0; i < sorted.size(); i++) { assertEquals(sorted.get(i).candidateScore, i); } }