int[] sorted = {10,67,68,28};
int[] sortedOriginal = sorted.clone();
Arrays.sort(sorted);
System.out.println(Arrays.asList(sorted).indexOf(sortedOriginal[0]));
In this very simple code I create an array of ints, clone it, and sort the original. After that I try to find the index given a certain value and it returns -1.
This doesn't make sense. Does anyone know why this happens and what the fix is?