### Question:
IdleRatioScanPrioritizer implements ScanPrioritizer { @Override public Comparator<ScanInfo> createComparator(CreateParameters params) { Preconditions.checkArgument(params.getOptions().isEmpty()); Comparator<ScanInfo> c1 = (si1, si2) -> { long currTime = System.currentTimeMillis(); return Double.compare(idleRatio(currTime, si1), idleRatio(currTime, si2)); }; return c1.thenComparingLong(si -> si.getLastRunTime().orElse(0)) .thenComparingLong(ScanInfo::getCreationTime); }  @Override Comparator<ScanInfo> createComparator(CreateParameters params);  }### Answer:
@Test public void testSort() { long now = System.currentTimeMillis(); List<TestScanInfo> scans = new ArrayList<>(); scans.add(new TestScanInfo("a", Type.SINGLE, now - 3)); scans.add(new TestScanInfo("b", Type.SINGLE, now - 8)); scans.add(new TestScanInfo("c", Type.SINGLE, now - 16, 2, 10)); scans.add(new TestScanInfo("d", Type.SINGLE, now - 16, 5, 10)); scans.add(new TestScanInfo("e", Type.SINGLE, now - 12, 5, 9)); scans.add(new TestScanInfo("f", Type.SINGLE, now - 12, 3, 7)); Collections.shuffle(scans); Comparator<ScanInfo> comparator = new IdleRatioScanPrioritizer().createComparator(new ScanPrioritizer.CreateParameters() { @Override public Map<String,String> getOptions() { return Collections.emptyMap(); } @Override public ServiceEnvironment getServiceEnv() { throw new UnsupportedOperationException(); } }); scans.sort(comparator); assertEquals("b", scans.get(0).testId); assertEquals("a", scans.get(1).testId); assertEquals("f", scans.get(2).testId); assertEquals("e", scans.get(3).testId); assertEquals("d", scans.get(4).testId); assertEquals("c", scans.get(5).testId); }