import java.util.*;
import java.lang.*;
import java.io.*;

class DescendingCompare implements Comparator<Integer> {
    public int compare(Integer a, Integer b) {
        if (a == b) {
            return 0;
        }
        
        if (a > b) {
            return -1;
        }
        
        return 1;
    }
}

class Main {
    public static void main(String[] args) {
        DescendingCompare cmp = new DescendingCompare();
        ArrayList<Integer> list = new ArrayList<>();
        list.add(5);
        list.add(10);
        list.add(3);
        list.add(4);
        
        list.sort(cmp);
        System.out.println(list); // prints: [10, 5, 4, 3]
    }
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: