### Question:
TimeComparator implements Comparator<Peer> { @Override public int compare(Peer p1, Peer p2) { long t1 = p1.getModified(); long t2 = p2.getModified(); return Long.compare(t2, t1); }  @Override int compare(Peer p1, Peer p2);  }### Answer:
@Test public void compareTest() { TimeComparator timeComparator = new TimeComparator(); Peer p1 = Peer.valueOf("ynode: Utils.sleep(1); Peer p2 = Peer.valueOf("ynode: long earlyJoinPeer = p1.getModified(); long latestJoinPeer = p2.getModified(); Assert.assertTrue(earlyJoinPeer < latestJoinPeer); Assert.assertTrue(timeComparator.compare(p1, p2) > 0); ArrayList<Peer> peerArrayList = new ArrayList<>(); peerArrayList.add(p1); peerArrayList.add(p2); peerArrayList.sort(timeComparator); Assert.assertEquals(p2, peerArrayList.get(0)); }