title: Java class comparable does not work
body: <p>I got a class used in an Android app, which is declared like this:</p>
  
  <pre><code>public static class MyData implements Comparable&lt;MyData&gt;
  {
     public MyEnum myEnum;
  
     @Override
     public int compareTo(MyData another)
     {
         if(this.myEnum.equals(MyEnum.Value1)) 
          {  
             return 1;
          }
         if(another.myEnum.equals(MyEnum.Value1)) 
          {
              return -1;
          }
         if(this.myEnum.equals(MyEnum.Value2)) 
         { 
              return 1;
         }
         if(another.myEnum.equals(MyEnum.Value2)) 
         {
            return -1;
         }
         return 0;
     }
  }
  </code></pre>
  
  <p>I defined a list: <code>List&lt;MyData&gt; myList = new LinkedList&lt;MyData&gt;();</code></p>
  
  <p>After adding items to the list I call: <code>Collections.sort(myList)</code></p>
  
  <p>The problem is that when I debug, I see the compareTo method being called after the sort method is invoked, however it doesn't enter the first if even that it should. I even put the Boolean expression in Eclipse in the "Expressions" view and it returned true, but the code simply jumps to the <code>return 0;</code> and the list is not being sorted like I want to.</p>
  
  <p>Why is that?</p>