title: Comparator using a double in Java
body: <p>This code</p>
  
  <pre><code>public class MyComparatorWinPCT implements Comparator&lt;Team&gt; {
  
  @Override
  public int compare(Team o1, Team o2) {
      // TODO Auto-generated method stub
      if(o1.rWinPCT &gt; o2.rWinPCT)
      {
          return -1;
      }
      if(o1.rWinPCT &lt; o2.rWinPCT)
      {
          return 0;
      }
  
      return 1;
   }
  
  }
  </code></pre>
  
  <p>Produces this output. </p>
  
  <blockquote>
    <p>Houston Rockets, 1, 0.793</p>
    
    <p>Golden State Warriors, 2, 0.707</p>
    
    <p>Atlanta Hawks, 3, 0.293</p>
    
    <p>Oklahoma City Thunder, 4, 0.585</p>
  </blockquote>
  
  <p>Here is how the method is invoked. </p>
  
  <pre><code>Collections.sort(teams, new MyComparatorWinPCT());
  </code></pre>
  
  <p>Win percentage is being used to compare and it's a double. I've tried every combo of the return statements but can't get it right. I need it in descending order based on win percentage. The highest win percentage first, then so on.  </p>