Following this question about sorting a list by another list, I tried to do the same thing - but from some reason it doesn't work for me. What am I missing?
List<Double> nums = Arrays.asList(5.0, 0.9, 10.4);
List<Double> order = Arrays.asList(3.0, 1.0, 2.0);
nums.sort(Comparator.comparing(order::indexOf));
System.out.println(nums);
OUTPUT: [5.0, 0.9, 10.4]
It should be [0.9, 10.4, 5.0] (according to order
). What am I not doing right?
EDIT: As most of you noticed, I got answer to the question I linked to all wrong. Here's what I actually want to do.