fork download
  1. import java.util.*;
  2. public class Main {
  3. public static void main(String[] args) {
  4. List<Integer> list = Arrays.asList(0, 5, 2, 1, 3, 2, 6, 1, 1, 0, 10);
  5. list.sort(Comparator.comparingInt(list::indexOf));
  6. System.out.println(list);
  7. }
  8. }
Success #stdin #stdout 0.09s 52140KB
stdin
Standard input is empty
stdout
[0, 0, 5, 2, 2, 1, 1, 1, 3, 6, 10]