modes:pair: adjust Pair::Ord

Instead of our more complicated interpretation before where we'd care
about whether something is proper or not, here we're just using a form
of reverse lexicographical on the Pair.
This commit is contained in:
2026-04-04 04:16:39 +01:00
committed by oreodave
parent 9690fb2bf3
commit 8bacbfbde3

View File

@@ -69,18 +69,15 @@ use std::cmp::Ordering;
impl Ord for Pair { impl Ord for Pair {
fn cmp(&self, other: &Self) -> Ordering { fn cmp(&self, other: &Self) -> Ordering {
/* /*
Comparison is slightly complicated by the inclusion of wild cards. Comparison is trivial: compare the top most card first. If they're
Rules are as follows: equivalent, then compare the last card to get a full ordering.
1) Two proper/improper pairs that have equivalent high cards are Otherwise, use the high card comparison.
equivalent.
2) Two pairs with equivalent high cards but only one is proper; the pair
that is proper wins.
3) Otherwise, comparison between high cards is the ordering.
*/ */
match (self.1.cmp(&other.1), self.is_proper(), other.is_proper()) { let high_card_comp = self.1.cmp(&other.1);
(Ordering::Equal, false, true) => Ordering::Less, if high_card_comp == Ordering::Equal {
(Ordering::Equal, true, false) => Ordering::Greater, self.0.cmp(&other.0)
(x, ..) => x, } else {
high_card_comp
} }
} }
} }