public int compareTo(ResourceUsage o){
  double required=o.limit - o.usage;
  double available=limit - usage;
  return Double.compare(available,required);
}

public int compareTo ( ResourceUsage o ) { double required = o . limit - o . usage ; double available = limit - usage ; return Double . compare ( available , required ) ; }
this may be wrong since we are comparing available and not the usage
