List<Integer> list = new ArrayList<>();
for(int i = 0 ; i <= 8 ; i ++){
list.add(i+1);
}
Collections.sort(list,(a, b)-> (a%b==0) ? 1 : (a%b==1) ? -1 : 0 );
list.forEach(System.out::println);
why the output is 1 4 3 5 7 2 6 9 8? How is the sorting done? Please Explain it briefly.
Here is a print-out of the values, as the comparison occurs.
Here is the modified code.