title: What might cause Collections.sort(List<T>, Comparator<? super T>) to throw a ClassCastException?
body: <p>I am calling Collections.sort() on an ArrayList using a Comparator that I declared earlier. </p>
  
  <pre><code>ArrayList&lt;Employee&gt; list = new ArrayList&lt;Employee&gt;();
  Comparator&lt;Employee&gt; comparator = new Comparator&lt;Employee&gt;() {
  
    public int compare(Employee o1, Employee o2) {
      return o1.getName().toLowerCase().compareTo(o2.getName().toLowerCase());
    }
  
  };
  
  ...
  
  Collections.sort(list, comparator);
  </code></pre>
  
  <p>For some reason, sort is trying to cast the elements of my ArrayList as Comparables, even though I passed a Comparator. Why might this be happening?</p>
  
  <p>If it's of any use, here is my stacktrace</p>
  
  <pre><code>Exception in thread "Thread-3" java.lang.ClassCastException: processing.app.EmployeeManager$PrettyOkayEmpolyee cannot be cast to java.lang.Comparable
      at java.util.Arrays.mergeSort(Unknown Source)
      at java.util.Arrays.sort(Unknown Source)
      at java.util.Collections.sort(Unknown Source)
      at foobar.Main.doSomeSorting(Main.java:140)
      ...
      at java.lang.Thread.run(Unknown Source)
  </code></pre>