diff --git a/base/src/main/java/smile/graph/NearestNeighborGraph.java b/base/src/main/java/smile/graph/NearestNeighborGraph.java index 8a6987366..03da54dc5 100644 --- a/base/src/main/java/smile/graph/NearestNeighborGraph.java +++ b/base/src/main/java/smile/graph/NearestNeighborGraph.java @@ -438,7 +438,7 @@ private static int[][] generateCandidates(List> heapList int[][] result = new int[n][]; for (int i = 0; i < n; i++) { List list = new ArrayList<>(candidates.get(i)); - list.sort((o1, o2) -> Double.compare(o1.distance, o2.distance)); + list.sort(Comparator.comparingDouble(o -> o.distance)); result[i] = list.stream().limit(maxCandidates).mapToInt(neighbor -> neighbor.index).toArray(); } return result;