Comparator violates transitivity

Code reviewHard25 minGoogle style

Your task

Review this Java comparator used to sort tasks by priority then by an int weight.

Tasks come from an upstream service and weights/priorities can be any 32-bit int, including large magnitudes. The team reports sporadic IllegalArgumentException: Comparison method violates its general contract! from TimSort, but only on certain shards.