Tried using some custom input, it always returns the correct output

package com.codegym.task.task26.task2601;
/*
Read online about the median of a sample
*/
import java.util.*;
public class Solution {
public static void main(String[] args) {
/*Integer[] test = {13, 8, 15, 5, 17,2};
Integer[] testResult = sort(test);
for (Integer i : testResult) System.out.println(i);*/
}
public static Integer[] sort(Integer[] array) {
// Implement the logic here
//coppy Array to ArrayList
/*ArrayList<Integer> list = new ArrayList<>();
list.addAll(Arrays.asList(array));
Collections.sort(list);*/
Arrays.sort(array);
//find median
int median = 0;
if (array.length%2 == 0) median = (array[array.length/2] + array[array.length/2 + 1])/2;
else median = array[array.length/2];
final int MEDIAN = median;
//create Comparator
Comparator<Integer> comparator = new Comparator<Integer>() {
@Override
public int compare(Integer o1, Integer o2) {
return Math.abs(o1-MEDIAN) - Math.abs(o2 - MEDIAN) ;
}
};
Arrays.sort(array, comparator);
return array;
}
}

1, 2, 3, 4} The number of elements is 4, so if you divide that in half you get two. The value at index two is 3. If you add 1 to the index you get three and the value at index three is 4. When dividing those you end up with a median of 3, however the correct median in this case is 2 because it should be taking index one (value: 2) and index two (value: 3) and dividing those by two. You can see this more clearly with this example: {1, 2, 3, 500} which outputs: 3 2 500 1 Also, I am not 100% sure on this next point, but after fixing the above and if it still is not passing, try converting MEDIAN to a double. The correct median in the above examples wouldn't be 2, it would be 2.5. I don't know how picky the validator is, but try that if it still does not pass.