mirror of
https://github.com/karpathy/nanochat.git
synced 2025-12-07 12:52:16 +00:00
use Ordering::then_wtth
This commit is contained in:
parent
67aaca98f5
commit
a13c9ca6ae
|
|
@ -112,12 +112,10 @@ impl PartialOrd for MergeJob {
|
||||||
impl Ord for MergeJob {
|
impl Ord for MergeJob {
|
||||||
fn cmp(&self, other: &Self) -> Ordering {
|
fn cmp(&self, other: &Self) -> Ordering {
|
||||||
// Max-heap by count; tie-break to ascending pair order (deterministic)
|
// Max-heap by count; tie-break to ascending pair order (deterministic)
|
||||||
if self.count != other.count {
|
self.count.cmp(&other.count).then_with(||
|
||||||
self.count.cmp(&other.count)
|
|
||||||
} else {
|
|
||||||
// ascending order on the pair when counts tie
|
// ascending order on the pair when counts tie
|
||||||
other.pair.cmp(&self.pair)
|
other.pair.cmp(&self.pair)
|
||||||
}
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user