### Question:
HintScanPrioritizer implements ScanPrioritizer { @Override public Comparator<ScanInfo> createComparator(CreateParameters params) { int defaultPriority = Integer .parseInt(params.getOptions().getOrDefault("default_priority", Integer.MAX_VALUE + "")); var tpb = ImmutableMap.<String,Integer>builder(); params.getOptions().forEach((k, v) -> { if (k.startsWith(PRIO_PREFIX)) { String type = k.substring(PRIO_PREFIX.length()); tpb.put(type, Integer.parseInt(v)); } }); Map<String,Integer> typePriorities = tpb.build(); HintProblemAction hpa = HintProblemAction.valueOf(params.getOptions() .getOrDefault("bad_hint_action", HintProblemAction.LOG.name()).toUpperCase()); Comparator<ScanInfo> cmp = Comparator.comparingInt(si -> getPriority(si, defaultPriority, hpa, typePriorities)); return cmp.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 - 7)); scans.add( new TestScanInfo("b", Type.SINGLE, now - 3).setExecutionHints("scan_type", "background")); scans.add( new TestScanInfo("c", Type.SINGLE, now - 4).setExecutionHints("scan_type", "background")); scans.add(new TestScanInfo("d", Type.SINGLE, now - 3).setExecutionHints("scan_type", "isbn")); scans.add(new TestScanInfo("e", Type.SINGLE, now - 5).setExecutionHints("scan_type", "isbn")); scans.add(new TestScanInfo("f", Type.SINGLE, now - 1).setExecutionHints("priority", "35")); scans.add(new TestScanInfo("g", Type.SINGLE, now - 2).setExecutionHints("priority", "25")); scans.add(new TestScanInfo("h", Type.SINGLE, now - 3).setExecutionHints("priority", "15")); scans.add(new TestScanInfo("i", Type.SINGLE, now - 4).setExecutionHints("priority", "5")); Collections.shuffle(scans); Comparator<ScanInfo> comparator = new HintScanPrioritizer().createComparator(new ScanPrioritizer.CreateParameters() { @Override public Map<String,String> getOptions() { return Map.of("priority.isbn", "10", "priority.background", "30", "default_priority", "20"); } @Override public ServiceEnvironment getServiceEnv() { throw new UnsupportedOperationException(); } }); scans.sort(comparator); assertEquals("i", scans.get(0).testId); assertEquals("e", scans.get(1).testId); assertEquals("d", scans.get(2).testId); assertEquals("h", scans.get(3).testId); assertEquals("a", scans.get(4).testId); assertEquals("g", scans.get(5).testId); assertEquals("c", scans.get(6).testId); assertEquals("b", scans.get(7).testId); assertEquals("f", scans.get(8).testId); }