title: Collections.sort vs Arrays.sort - in Java
body: <p>I was doing this sort first: </p>
  
  <pre><code>List&lt;String&gt; items = new ArrayList&lt;String&gt;();
  
  Comparator&lt;items&gt; ignoreLeadingThe = new Comparator&lt;items&gt;() {
      public int compare(String a, String b) {
          a = a.replaceAll("(?i(^the\\s+", "");
          b = b.replaceAll("(?i(^the\\s+", "");
          return a.compareToIgnoreCase(b);
      }
  };
  
  Collections.sort(items, ignoreLeadingThe);
  </code></pre>
  
  <p>now I am doing this:</p>
  
  <pre><code>ItemObject[] io = new ItemObject[items.size()];
  
  Comparator&lt;ItemObject&gt; ignoreLeadingThe = new Comparator&lt;ItemObject&gt;() {
      public int compare(ItemObject a, ItemObject b) {
          a.name = a.name.replaceAll("(?i(^the\\s+", "");
          b.name = b.name.replaceAll("(?i(^the\\s+", "");
          return a.name.compareToIgnoreCase(b.name);
      }
  };
  
  Arrays.sort(io, ignoreLeadingThe);
  </code></pre>
  
  <p>When I was sorting the <code>ArrayList</code> up top, it acted as normal; it ignored the "The " and sorted list accordingly; but it wasn't actually effecting the output of the list.</p>
  
  <p>However, the bottom code when I am sorting a regular <code>Array</code> (filled with Objects and not Strings), actually remove "The ".  For example,  "The Joker", would become "Joker".</p>
  
  <p>Does anyone see what is going wrong here?</p>