title: Using CompareTo to compare both a string and a double value within an array?
body: <p>I am given an assignment to sort an array of inputted values using both insertion sort and selection sort. I am having some trouble with overwriting the <code>compareTo</code> method with in the <code>Item</code> class. I would like it to sort so that if two items are priced the same it then compares based on <code>Category</code>. So Child (C) items come first and then M and then Women. This is my code and every time that I attempt to compile it I get an error saying that <code>double</code> cannot be referenced.</p>
  
  <pre><code>public int compareTo (Object other) {
        int result;
  
        double otherPrice = ((Item)other).getClothPrice();
        String otherCategory = ((Item)other).getClothCategory();
  
        if (clothPrice == otherPrice)
           result = clothCategory.compareTo(otherCategory);
        else
           result = clothPrice.compareTo(otherPrice);
  
        return result;
  }
  </code></pre>