3

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
1
  • 8
    An int[] is not an Integer[]. Commented Jan 25, 2014 at 2:54

1 Answer 1

1

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);
Sign up to request clarification or add additional context in comments.

2 Comments

I don't think that will work. You need to make all the ints Integers instead. Otherwise you're invoking compareTo() on an int.
This will not compile

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.