title: Comparable arrayList with object with double variable
body: <p>I'm trying to sort an arrayList with a object I created called TextObject. I'd like to sort the arrayList is ascending value, based on a double value stored in the TextObject. I am able to make a comparable for int but struggling with doubles.</p>
  <p>Here is my textObject code implementing Comparable:</p>
  <pre><code>public class TextObject implements Comparable&lt;TextObject&gt; {
  private String line = &quot;&quot;;
  private int lineNum = 0;
  private double score;
  
  /**
   * constructor to build TO
   * @param lineScore
   * @param line
   * @param lineNum
   */
  TextObject(String line, int lineNum){
      //this.lineScore = lineScore;
      this.line = line;
      this.lineNum = lineNum;
  }
  
  
  /**
   * to string method to print it out
   */
  @Override
  public String toString() {
      return &quot;TextObject [line=&quot; + line + &quot;, lineNum=&quot; + lineNum + &quot;, score=&quot; + score + &quot;]&quot;;
  }
  
  @Override
  public double compareTo(TextObject comparestu) {
      double compareScore=((TextObject)comparestu).getScore();
      return this.score-compareScore;
  }
  
  
  /**
   * @return the score
   */
  public double getScore() {
      return score;
  }
  }
  </code></pre>
  <p>Then I'm calling the arrayList using Collections.sort from another class:</p>
  <pre><code>     Collections.sort(st.getLinesArr());
       for(TextObject to : st.getLinesArr()){
          System.out.println(to);
     }
  </code></pre>
  <p>I'd like help with the comparable method.</p>