fwriteErr
fwriteErr

Reputation: 73

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

Upvotes: 3

Views: 467

Answers (1)

NULL
NULL

Reputation: 313

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);

Upvotes: 1

Related Questions