I think the code would work better if you changed it:
@Override
public int compareTo(ItemSales item) {
if (this.totalSales < item.totalSales) {
return -1;
}
else if(this.totalSales > item.totalSales){
return 1;
}
return 0;
}
The problem with your earlier Double.compare() was that you had the parameters in wrong order, it should have been compare(this, item) and not the other way around