Program does what it should. I have no idea whats wrong?
package com.codegym.task.task26.task2601;
/*
Read online about the median of a sample
*/
import java.util.Arrays;
import java.util.Comparator;
public class Solution {
public static void main(String [] args) {
}
public static Integer[] sort(Integer[] array) {
Arrays.sort(array, new Comparator<Integer>() {
@Override
public int compare(Integer i1, Integer i2) {
int median = array[0];
int dif1 = i1 - median;
int dif2 = i2 - median;
if(dif1 < 0)
dif1 = -dif1;
if(dif2 < 0)
dif2 = -dif2;
int comp = Integer.compare(dif1, dif2);
if(comp == 0)
return Integer.compare(i1, i2);
else
return comp;
}
});
return array;
}
}