int (String id1, String id2, @NotNull Object2LongMap<String> latencies) { long latency1 = latencies.getOrDefault(id1, Long.MAX_VALUE); long latency2 = latencies.getOrDefault(id2, Long.MAX_VALUE); return Long.compare(latency1, latency2); }