diff --git a/rustbpe/src/lib.rs b/rustbpe/src/lib.rs index b43fb6c..3605072 100644 --- a/rustbpe/src/lib.rs +++ b/rustbpe/src/lib.rs @@ -112,12 +112,10 @@ impl PartialOrd for MergeJob { impl Ord for MergeJob { fn cmp(&self, other: &Self) -> Ordering { // Max-heap by count; tie-break to ascending pair order (deterministic) - if self.count != other.count { - self.count.cmp(&other.count) - } else { + self.count.cmp(&other.count).then_with(|| // ascending order on the pair when counts tie other.pair.cmp(&self.pair) - } + ) } }