The order of comparison is: network first, then disk, then CPU. The comparison here happens each time
primarily after the heuristic costs, then after the quantifiable costs.

@see java.lang.Comparable#compareTo(java.lang.Object)
497277
@Override
	public int compareTo(Costs o) {
		// check the network cost. if we have actual costs on both, use them, otherwise use the heuristic costs.
		if (this.networkCost != UNKNOWN && o.networkCost != UNKNOWN) {
			if (this.networkCost != o.networkCost) {
				return this.networkCost < o.networkCost ? -1 : 1;
			}
		} else if (this.heuristicNetworkCost < o.heuristicNetworkCost) {
			return -1;
		} else if (this.heuristicNetworkCost > o.heuristicNetworkCost) {
			return 1;
		}
		
		// next, check the disk cost. again, if we have actual costs on both, use them, otherwise use the heuristic costs.
		if (this.diskCost != UNKNOWN && o.diskCost != UNKNOWN) {
			if (this.diskCost != o.diskCost) {
				return this.diskCost < o.diskCost ? -1 : 1;
			}
		} else if (this.heuristicDiskCost < o.heuristicDiskCost) {
			return -1;
		} else if (this.heuristicDiskCost > o.heuristicDiskCost) {
			return 1;
		}
		
		// next, check the CPU cost. again, if we have actual costs on both, use them, otherwise use the heuristic costs.
		if (this.cpuCost != UNKNOWN && o.cpuCost != UNKNOWN) {
			return this.cpuCost < o.cpuCost ? -1 : this.cpuCost > o.cpuCost ? 1 : 0;
		} else if (this.heuristicCpuCost < o.heuristicCpuCost) {
			return -1;
		} else if (this.heuristicCpuCost > o.heuristicCpuCost) {
			return 1;
		} else {
			return 0;
		}
	}
180065
public static <T extends Comparable> int compare(@Nullable T first, @Nullable T second) {
        return compare(first, second, Comparable::compareTo);
    }
1090049
@Override
    public int compareTo(Object o) {
        HashCalculationResult myClass = (HashCalculationResult) o;
        return new CompareToBuilder()
                .append(this.fullHash, myClass.fullHash)
                .append(this.mostSigBitsHash, myClass.mostSigBitsHash)
                .append(this.leastSigBitsHash, myClass.leastSigBitsHash)
                .toComparison();
    }
475773
@Override
    public int compareTo(ServicePath servicePath) {
        // longer paths come first
        if (segments.length != servicePath.segments.length) {
            return servicePath.segments.length - segments.length;
        }
        else {
            for (int i = 0; i < segments.length; i++) {
                boolean segmentIsParam = isParam(segments[i]);
                boolean serviceSegmentIsParam = isParam(servicePath.segments[i]);
                // non-params first
                if (segmentIsParam && !serviceSegmentIsParam)
                    return 1;
                else if (serviceSegmentIsParam && !segmentIsParam)
                    return -1;
            }
            return path.compareTo(servicePath.path);
        }
    }
819734
public int compareTo(ExtensionComponent<T> that) {
        double a = this.ordinal();
        double b = that.ordinal();
        if (a>b)    return -1;
        if (a<b)    return 1;

        // make the order bit more deterministic among extensions of the same ordinal
        if (this.instance instanceof Descriptor && that.instance instanceof Descriptor) {
            try {
                return Util.fixNull(((Descriptor)this.instance).getDisplayName()).compareTo(Util.fixNull(((Descriptor)that.instance).getDisplayName()));
            } catch (RuntimeException | LinkageError x) {
                LOG.log(Level.WARNING, null, x);
            }
        }
        return this.instance.getClass().getName().compareTo(that.instance.getClass().getName());
    }
543591
@Override
    public int compareTo(Storage o) {
        return ComparisonChain.start()
                .compareTrueFirst(isConsistent(), o.isConsistent())  // Primaries *must* be consistent.
                .compareTrueFirst(_masterPrimary, o._masterPrimary)  // Master primary sorts first
                .compare(o.getPromotionId(), getPromotionId(), TimeUUIDs.ordering().nullsLast())  // Facade primary sorts first
                .compare(_uuid, o._uuid)  // Break ties in a way that's compatible with equals()
                .result();
    }
1300822
@Override
  public int compareTo(ID o) {
    TaskAttemptID that = (TaskAttemptID)o;
    int tipComp = this.taskId.compareTo(that.taskId);
    if(tipComp == 0) {
      return this.id - that.id;
    }
    else return tipComp;
  }
825312
@Override
    public int compareTo(PlainTime time) {

        int delta = this.hour - time.hour;

        if (delta == 0) {
            delta = this.minute - time.minute;
            if (delta == 0) {
                delta = this.second - time.second;
                if (delta == 0) {
                    delta = this.nano - time.nano;
                }
            }
        }

        return ((delta < 0) ? -1 : ((delta == 0) ? 0 : 1));

    }
985326
public int compareTo (ConfigField o)
    {
        return ComparisonChain.start().compare(name, o.name).result();
    }
797840
public int compareTo(WebPage o) {
        int result;
        // first compare by priority
        result = PRIORITY_COMPARATOR.compare(this.getPriority(), o.getPriority());
        // next compare by shortName
        if (result == 0) {
            result = SHORT_NAME_COMPARATOR.compare(this.getShortName(), o.getShortName());
        }
        return result;
    }
421850
@Override
    public int compareTo(ObserverMethod o) {
        if (o == null) {
            return 1;
        }
        Integer a = getPresedence(getMethod());
        Integer b = getPresedence(o.getMethod());
        return b.compareTo(a);
    }
1012410
@Override
    public int compareTo(@NonNull Operation another) {
        return another.definedPriority().priority - definedPriority().priority;
    }
622217
@Override
    public int compareTo(PrefixedChecksummedBytes o) {
        int result = this.params.getId().compareTo(o.params.getId());
        return result != 0 ? result : UnsignedBytes.lexicographicalComparator().compare(this.bytes, o.bytes);
    }
403206
@Override
  public int compareTo(Object o) {
    SortedClassProbability other = (SortedClassProbability) o;
    if (this.probability < other.probability) {
      return -1;
    }
    else if (this.probability > other.probability) {
      return 1;
    }
    else {
      return 0;
    }
  }
478133
@Override
  public int compare(final Object o1, final Object o2) {
    return String.CASE_INSENSITIVE_ORDER.compare(String.valueOf(o1), String.valueOf(o2));
  }
1239574
@Override
    public int compareTo(final FastZipEntry o) {
        final int diff0 = o.version - this.version;
        if (diff0 != 0) {
            return diff0;
        }
        final int diff1 = entryNameUnversioned.compareTo(o.entryNameUnversioned);
        if (diff1 != 0) {
            return diff1;
        }
        final int diff2 = entryName.compareTo(o.entryName);
        if (diff2 != 0) {
            return diff2;
        }
        // In case of multiple entries with the same entry name, return them in consecutive order of location,
        // so that the earliest entry overrides later entries (this is an arbitrary decision for consistency)
        final long diff3 = locHeaderPos - o.locHeaderPos;
        return diff3 < 0L ? -1 : diff3 > 0L ? 1 : 0;
    }
484971
public void order() {
        Collections.sort(cells, new Comparator<SortedSet<Integer>>() {

            @Override
            public int compare(SortedSet<Integer> cellA, SortedSet<Integer> cellB) {
                return cellA.first().compareTo(cellB.first());
            }

        });
    }