From 8bacbfbde31ac60b5db10ebaa71a38f4a92b4930 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Sat, 4 Apr 2026 04:16:39 +0100 Subject: [PATCH] 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. --- src/modes/pair.rs | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/modes/pair.rs b/src/modes/pair.rs index 051445d..3b2ff7d 100644 --- a/src/modes/pair.rs +++ b/src/modes/pair.rs @@ -69,18 +69,15 @@ use std::cmp::Ordering; impl Ord for Pair { fn cmp(&self, other: &Self) -> Ordering { /* - Comparison is slightly complicated by the inclusion of wild cards. - Rules are as follows: - 1) Two proper/improper pairs that have equivalent high cards are - 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. + Comparison is trivial: compare the top most card first. If they're + equivalent, then compare the last card to get a full ordering. + Otherwise, use the high card comparison. */ - match (self.1.cmp(&other.1), self.is_proper(), other.is_proper()) { - (Ordering::Equal, false, true) => Ordering::Less, - (Ordering::Equal, true, false) => Ordering::Greater, - (x, ..) => x, + let high_card_comp = self.1.cmp(&other.1); + if high_card_comp == Ordering::Equal { + self.0.cmp(&other.0) + } else { + high_card_comp } } }