/*
 * @(#)ByWeightComparator.java
 *
 * Summary: Sort Trucks by weight.
 *
 * Requires: JDK 1.5+
 *
 * Created with: Canadian Mind Products ComparatorCutter.
 *
 * Version History:
 *  1.0 2009-05-23 - initial release
 */
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&gt;b, 0 if a==b, -ve if a&lt;b
     */
    public final int compare( Object a, Object b )
        {
        return Misc.signum( ( ( Truck ) a ).weight - ( ( Truck ) b ).weight );
        }
    }