Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Arrays.Sort(arr, comparator); does not accept arguments

Can't sort multidinensional array.

static int ccheck[][] = new int[6*6*6][4];

    Comparator<Integer[]> comp = new Comparator<Integer[]>() {
        @Override
        public int compare(Integer[] t, Integer[] t1) {
            Integer in1 = t[3];
            Integer in2 = t1[3];
            return in1.compareTo(in2);                
        }
    };
    Arrays.sort(ccheck, comp);

causes

error: java.lang.RuntimeException: Uncompilable source code - Erroneous sym type: java.util.Arrays.sort
like image 263
fwriteErr Avatar asked Aug 25 '26 23:08

fwriteErr


1 Answers

Try changing your code to:

static Integer ccheck[][] = new Integer[6*6*6][4];

    Comparator<Integer[]> comp = new Comparator<Integer[]>() {
    @Override
    public Integer compare(Integer[] t, Integer[] t1) {
        Integer in1 = t[3];
        Integer in2 = t1[3];
        return in1.compareTo(in2);                
        }
    };
    Arrays.sort(ccheck, comp);
like image 117
NULL Avatar answered Aug 28 '26 12:08

NULL



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!