title: Help comparing float member variables using Comparators
body: <p>I am able to compare Strings fine, but would like to know how I can rank floating point numbers?</p>
  
  <p>getChange() returns a String. I want to be able to sort descending. How can I do this?</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <pre><code>package org.stocktwits.helper;
  
  import java.util.Comparator;
  
  import org.stocktwits.model.Quote;
  
  public class ChangeComparator implements Comparator&lt;Quote&gt;
  {
      public int compare(Quote o1, Quote o2) {
          float change1 = Float.valueOf(o1.getChange());
          float change2 = Float.valueOf(o2.getChange());
  
          if (change1 &lt; change2) return -1;
          if (change1 == change2) return 0; // Fails on NaN however, not sure what you want
          if (change2 &gt; change2) return 1;
      }
  }
  </code></pre>
  
  <p>I am getting the compile time error:</p>
  
  <pre><code>This method must return a result of type int    ChangeComparator.java   
  </code></pre>