title: Java Collection sort BigDecimal
body: <p>I'm trying to sort an ArrayList by BigDecimal and coming up against a brickwall.  I have a class that looks a little like this:</p>
  
  <pre><code>public class deal implements Comparable&lt;deal&gt;{
  
  protected BigDecimal bdPrice;
  protected int iQuantity;
  protected String sDealType;
  protected UUID dealUniqueID;
  protected int dealID;
  protected BigDecimal bdUnitPrice;
  
  public deal(){
      bdPrice         = new BigDecimal("0");
      bdUnitPrice     = new BigDecimal("0");
      iQuantity       = 1;
      sDealType       = "Single item";
      dealUniqueID    = UUID.randomUUID();
      dealID          = 0;
  }
  
  private void setUnitPrice(){
      this.bdUnitPrice = this.bdPrice.divide(new BigDecimal(this.iQuantity));
  }
  
  public BigDecimal compareTo(deal oDeal) {
      // TODO Auto-generated method stub
      return bdUnitPrice.compareTo(oDeal.getUnitPrice());
  }
  
  public boolean equals(deal oDeal) {
      if (!(oDeal instanceof deal))
          return false;
      deal oD = (deal) oDeal;
  
      return this.bdUnitPrice.equals(oD.bdUnitPrice);
  }
  }
  </code></pre>
  
  <p>and my main Android Activity looks like this:</p>
  
  <pre><code>public class SupermarketDealsActivity extends Activity {
  private ArrayAdapter&lt;deal&gt; itemAdapter;
  private ListView lvDeals;
  private ArrayList&lt;deal&gt; itemArray;
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
      SetUpView();
  }
  
  private void SetUpView(){
  lvDeals                     = (ListView)this.findViewById(R.id.listDeals);
  
      itemArray                   = new ArrayList&lt;deal&gt;();
      itemArray.clear();
  
      itemAdapter                 = new ArrayAdapter&lt;deal&gt;(this, android.R.layout.simple_list_item_1,itemArray);
      lvDeals.setAdapter(itemAdapter);
  }
  
  private void CreateADeal(int iQuantity, BigDecimal bdPrice) {
      deal oDeal                  = new deal();
  
      oDeal.setQuantity(iQuantity);
      oDeal.setPrice(bdPrice);
  
      CreateListDeals(oDeal);
  }
  
  private void CreateListDeals(deal oDeal){
      itemArray.add(oDeal);
      Collections.sort(itemArray,Collections.reverseOrder());
      itemAdapter.notifyDataSetChanged();
  }
  }
  </code></pre>
  
  <p>In my java class I am getting an error with my compareTo method saying:</p>
  
  <blockquote>
    <p>Type mismatch: cannot convert from int to BigDecimal</p>
  </blockquote>
  
  <p>I must have missed something along the way, what is it?</p>
  
  <p>Cheers</p>