• + 2 comments

    Collections.sort(Collection, Comparator) and Collections.sort(Collection) are overloaded method. And we need to use the first form here, which will take a Comparator as the second parameter, since reference type does not have a natural ordering.

    The Comparator interface consists of a single method.

    public interface Comparator<T> {
        int compare(T o1, T o2);
    }
    

    The compare method compares its two arguments, returning a negative integer, 0, or a positive integer depending on whether the first argument is less than, equal to, or greater than the second.

    As we need decreasing order, therefore the comperator should return a positive value when the order appears to be increasing, so that it will change the order and make it decreasing again. Hence, b.score - a.score.