title: Collections.sort(List<T> t, Comparator<T> c) don't work
body: <p>I was trying to implement custom ordering of integer array. The logic is : find median and order by distance to it. The thing is that I tried to sort using Comparator , and was wondering why variant with List don't work, while the same Arrays.sort worked for me.</p>
  
  <p>Please find code below, under comments are lines used for List variant.</p>
  
  <pre><code>public static Integer[] sort(Integer[] array) {
      //implement logic here
      if (array == null) return null;
      final Integer[] tempArray = Arrays.copyOf(array, array.length);
      Arrays.sort(tempArray);
      final int median = tempArray.length%2==1 ? tempArray[tempArray.length/2] : (tempArray[tempArray.length/2]+tempArray[tempArray.length/2 - 1])/2;
  
  
  
      //final List&lt;Integer&gt; t = new ArrayList(Arrays.asList(array));
      final Integer[] t = tempArray;
      //Collections.sort(t, new Comparator&lt;Integer&gt;()
      Arrays.sort(t, new Comparator&lt;Integer&gt;()
      {
          @Override
          public int compare(Integer i1, Integer i2)
          {
              Integer one = Math.abs(i1 - median);
              Integer two = Math.abs(i2 - median);
              Integer var1 = one - two;
              Integer var2 = two - one;
              System.out.println(String.format("Compare:\r\nmedian: %d\r\narg1: %d , arg2: %d\r\n"+
                      "distance1: %d, distance2: %d\r\nif dist1 &gt; dist2 then compare: %d, else %d", median, i1, i2,one,two, var2,var1));
              System.out.println(String.format("\r\nresult: %d %s %d",i1, (one &gt;  two?"&lt;":one &lt; two?"&gt;":i1.compareTo(i2)&gt;0?"&gt;":"&lt;"), i2));
              System.out.println("\r\n\r\nNow array is: "+Arrays.asList(t));
              System.out.println("-------------------------------");
  
              if (one ==  two) {
                  return i1.compareTo(i2);
              } else
                  return one.compareTo(two);
          }
      });
  
      //tempArray = (Integer[]) t.toArray(new Integer[t.size()]);
  
      return t;
  }``
  </code></pre>