title: Collections.sort() throws Comparison method violates its general contract! exception
body: <p>I'm trying to sort a List&lt;> object and I get this exception thrown (for large lists only though)</p>
  
  <p>sorting code:</p>
  
  <pre><code>List&lt;FinalSentence&gt; sentenceList = finalRepresentation.getSentences();
  Collections.sort(sentenceList); // &lt;=== EXCEPTION THROWN HERE!!!
  </code></pre>
  
  <p>FinalSentence class header:</p>
  
  <pre><code>public class FinalSentence implements Comparable&lt;FinalSentence&gt;{...}
  </code></pre>
  
  <p>compareTo() implementation:</p>
  
  <pre><code>@Override
  public int compareTo(FinalSentence o) {
      if (this == o) {
          return 0;
      }
      if (this.score &gt; o.score) {
          return 1;
      }
      if (this.score &lt; o.score) {
          return -1;
      }
      return 0;
  }
  </code></pre>
  
  <p>this is the exception:</p>
  
  <pre><code>Exception in thread "main" java.lang.IllegalArgumentException: Comparison method violates its general contract!
  at java.util.ComparableTimSort.mergeHi(Unknown Source)
  at java.util.ComparableTimSort.mergeAt(Unknown Source)
  at java.util.ComparableTimSort.mergeCollapse(Unknown Source)
  at java.util.ComparableTimSort.sort(Unknown Source)
  at java.util.ComparableTimSort.sort(Unknown Source)
  at java.util.Arrays.sort(Unknown Source)
  at java.util.Collections.sort(Unknown Source)
  at feature.finalRepresentation.Summarizer.summarize(Summarizer.java:30)
  at driver.Driver.main(Driver.java:114)
  </code></pre>
  
  <p>for a small list (less than 50 elements) it works. for a large list (it's supposed to work with those as well) it throws this exception.
  The instance type of the List is ArrayList, not that it should matter.</p>
  
  <p>I have no idea how to get to the bottom of this. The list is full, the elements are of the same type (no polymorphism there) and yet I get this weird exception for large lists.</p>
  
  <p>Any ideas?</p>
  
  <p>Thanks ahead!!!</p>