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?
The Comparator you are supplying calls indexOf for every num passed.
The returned values are -1 on all calls, so the order is preserverd as-is.
You need to sort natural.
Sorting by another list of Double should be possible, but unnecessarily complicated, it would be simpler to provide a custom Object which sorts as desired.