import java.util.Comparator;
/**
* Sort Trucks by weight.
* <p/>
* Defines an alternate sort order for Truck.
*
* @author Roedy Green
* @version 1.0 2009-05-23 - initial release
* @since 2009-05-23
*/
class ByWeightComparator implements Comparator
{
/**
* Sort Trucks by weight.
* Defines an alternate sort order for Truck without JDK 1.5+ generics.
* Compare two Truck Objects.
* Compares weight.
* Informally, returns (a-b), or +ve if a is more positive than b.
*
* @param a first Truck to compare
* @param b second Truck to compare
*
* @return +ve if a>b, 0 if a==b, -ve if a<b
*/
public final int compare( Object a, Object b )
{
return Misc.signum( ( ( Truck ) a ).weight - ( ( Truck ) b ).weight );
}
}