### Question:
PrioritizedServiceComparator implements Comparator<S> { @Override public int compare(S o1, S o2) { int result = -1 * Integer.compare(o1.getServicePriority(), o2.getServicePriority()); if (result == 0) { result = Integer.compare(o1.hashCode(), o2.hashCode()); } return result; }  @Override int compare(S o1, S o2);  }### Answer:
@Test public void testCompare() throws Exception { PrioritizedService s1 = () -> 10; PrioritizedService s2 = () -> 20; PrioritizedService s3 = () -> 30; SortedSet<PrioritizedService> set = new TreeSet<>(new PrioritizedServiceComparator<>()); set.add(s2); set.add(s3); set.add(s1); assertEquals(set.size(), 3); assertEquals(set.first(), s3); assertEquals(set.last(), s1); }