title: no suitable method found for sort(int[],<anonymous Comparator<Integer>>)
body: <p>Algorithm question: Given a list of non negative integers, arrange them such that they form the largest number.</p>
  
  <p>For example, given [3, 30, 34, 5, 9], the largest formed number is 9534330.</p>
  
  <p>Note: The result may be very large, so you need to return a string instead of an integer.</p>
  
  <pre><code>    public class Solution {
      public String largestNumber(int[] num) {
          Arrays.sort(num, new java.util.Comparator&lt;Integer&gt;() {
              @Override
              public int compare(Integer a, Integer b) {
                  String s1 = String.valueOf(a), s2 = String.valueOf(b);
                  return Integer.parseInt(s1 + s2) - Integer.parseInt(s2 + s1);
              }
          });
          StringBuilder builder = new StringBuilder();
          for (int i = num.length - 1; i &gt;= 0; i--)   builder.append(num[i]);
          return builder.toString();
      }
  }
  </code></pre>
  
  <p>Result: Line 3: error: no suitable method found for sort(int[],&lt;anonymous Comparator&lt;Integer>>)</p>
  
  <p>Does anyone know how to modify it? Thanks!</p>
  
  <p>Thank you for all your detail answers, I have modified my code as </p>
  
  <pre><code>public String largestNumber(int[] num) {
      int N = num.length;
      String[] aux = new String[N];
      for (int i = 0; i &lt; N; i++) aux[i] = String.valueOf(num[i]); // int[] -&gt; String[]
      Arrays.sort(aux, new Comparator&lt;String&gt;() {
          @Override
          public int compare(String a, String b) {
              return (int) (Long.parseLong(a + b) - Long.parseLong(b + a));  // note the overflow of int, max + max
          }
      });
      StringBuilder builder = new StringBuilder();
      for (int i = N - 1; i &gt;= 0; i--)    builder.append(aux[i]);
      int sub = 0;
      for ( ; sub &lt; builder.length() - 1 &amp;&amp; builder.charAt(sub) == '0'; sub++);
      return builder.substring(sub).toString();
  }
  </code></pre>
  
  <p>And I am still trying to find a way to avoid using extra space.</p>