title: java: Arrays.sort() with lambda expression
body: <p>I want to sort String elements in the array <code>months</code> by length using <code>Arrays.sort</code> method. I was told <a href="http://docs.oracle.com/javase/tutorial/java/javaOO/methodreferences.html" rel="noreferrer">here</a>, that it's possible to use lambda expressions instead of creating new class implementing Comparator. Did it exactly the same way, yet it doesn't work.</p>
  
  <pre><code>import java.util.Arrays;
  import java.util.Comparator;
  
  public class MainClass {
  public static void main(String[] args)
  {
  
      String[] months = {"January","February","March","April","May","June","July","August","September","October","December"};
  
      System.out.println(Arrays.toString(months)); //printing before
  
  
      //neither this works:
      Arrays.sort(months, 
              (a, b) -&gt; Integer.signum(a.length() - b.length())   
      );
  
      //nor this:
      Arrays.sort(months, 
              (String a, String b) -&gt; { return Integer.signum(a.length() - b.length()) }; 
      );
  
  
      System.out.println(Arrays.toString(months)); //printing after
  }
  }
  </code></pre>