0

I have class Matrix and must sort the last row using comparator.My class is:

public class Matrix{
private int matrix[][];
public void sort(int n)
}

I'am trying to write like this

`Arrays.sort(matrix[n], (Integer a, Integer b) -> {
    return b.compareTo(a);
});

But i have Error "Cannot infer functional interface type" I have resolved this error: private Integer matrix[][] fixed that error. Thnks for help

Vladislav
  • 67
  • 8
  • 1
    You're stating something like "my code doesn't work", but this doesn't help us understand what's wrong or how to help you. Please see [this link for more on this](http://meta.stackoverflow.com/questions/258685/should-we-have-a-more-specific-close-reason-for-vague-debugging-questions), and then please edit and improve your question. – Hovercraft Full Of Eels Sep 30 '16 at 22:00
  • `Arrays.sort(int[])` doesn't accept or need a comparator. – shmosel Sep 30 '16 at 22:01
  • I don't think this question is that vague. He is trying to sort an array using a comparator, he shows 2 things he has tried that don't work. – nhouser9 Sep 30 '16 at 22:02
  • @nhouser9: The code doesn't work, how? Does it compile? Does it run? Does it insult him and make him write bad checks? – Hovercraft Full Of Eels Sep 30 '16 at 22:03
  • .... OK, now we have more useful information. – Hovercraft Full Of Eels Sep 30 '16 at 22:04
  • @shmosel yes, i tried without Comparator, i works, but i want to know how to use Comparator – Vladislav Sep 30 '16 at 22:06
  • Possible duplicate of [How to sort an array of ints using a custom comparator?](http://stackoverflow.com/q/3699141/1553851) – shmosel Sep 30 '16 at 22:08

0 Answers0