title: Sorting ArrayList by sting length in java
body: <p>I have an ArrayList</p>
  
  <pre><code>ArrayList&lt;String[]&gt; matches = new ArrayList&lt;String[]&gt;();
  
  Collections.sort(matches, new Comparator&lt;String&gt;() {
      @Override
      public int compare(String word1, String word2) {
          return word2.length() - word1.length();
          }
      });
  </code></pre>
  
  <p>I want to sort this ArrayList by the length of the strings in the ArrayList. I want the list to be in descending order.</p>
  
  <pre><code>Input = ace, a, apple, cord
  
  Output = apple, cord, ace, a
  </code></pre>