Why does he multiply v1 and v2 with themselves and then multiply the result by 100?

```
public static Integer[] sort(Integer[] array) {
final double mediana = getMediana(array);
Arrays.sort(array, new Comparator<Integer>() {
@Override
public int compare(Integer o1, Integer o2) {
double v1 = o1.intValue() - mediana;
double v2 = o2.intValue() - mediana;
return (int) ((v1 * v1 - v2 * v2) * 100);
}
});
```

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) {
Integer[] array = new Integer[]{13,8,15,5,17};
sort(array);
for (Integer integer : array) System.out.println(integer);
}
public static Integer[] sort(Integer[] array) {
// Implement the logic here
//identify the median
double median = getMedian(array);
//System.out.println(median);
//least difference from the median first. if difference identical, sort ascending
Comparator<Integer> medianComp = new Comparator<Integer>() {
@Override
public int compare(Integer o1, Integer o2) {
return (int) (o1.intValue() - median - o2.intValue() - median);
}
};
Arrays.sort(array);
return array;
}
public static double getMedian(Integer[] array){
// First we sort the array
Arrays.sort(array);
// check for even case
if (array.length % 2 != 0)
return (double)array[array.length / 2];
return (double)(array[array.length / 2 - 1] + array[array.length / 2]) / 2.0;
}
}

(-2 - 2) * 100or(2 - -2) * 100[depending on which one was o1 and which was o2] resulting in either -400 or 400. If you do that then one will clearly will be greater than the other, however in this scenario they are both the same. Now if you multiply them both then the equation looks more like this:(4-4) * 100which results in the correct answer of 0. I don't like the solution however as: works and is way easier to read/understandDouble.compare(double arg1, double arg2)will return - a positive int if the first argument is greater than the second - a negative int if the first argument is less than the second - 0 if both arguments are equal You also have Integer.compare(), Short.compare(), Boolean.compare(), Long.compare() etc... all do the same exact thing. Also, there is a compareTo() method on classes that implement the Comparable interface that works the same exact way. One example is the String class:"some string".compareTo("some other string") This would return: - a positive int if the first argument is greater than the second - a negative int if the first argument is less than the second - 0 if both arguments are equal Most Java standard objects have the compareTo() method implemented. You can make your own classes that implement this by just adding: class MyClassimplements Comparable<MyClass>to your class definition. You then have to write the logic for the compareTo(MyClass o) method keeping in mind that you want to return - a positive int in the case that the object (this) is greater than the compared object (o) - a negative int in the case that the object is less than the compared object - 0 if both objects are identical