From ca54b949539c8dd6033eacb9cab0cfac324b7a22 Mon Sep 17 00:00:00 2001 From: RunasSudo Date: Wed, 16 Jun 2021 18:23:47 +1000 Subject: [PATCH] Show keep values for elected candidates in Meek STV --- src/main.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 3e02513..bbb057c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -250,13 +250,17 @@ where let mut winners = Vec::new(); for (candidate, count_card) in state.candidates.iter() { if count_card.state == CandidateState::Elected { - winners.push((candidate, count_card.order_elected)); + winners.push((candidate, count_card)); } } - winners.sort_unstable_by(|a, b| a.1.partial_cmp(&b.1).unwrap()); + winners.sort_unstable_by(|a, b| a.1.order_elected.partial_cmp(&b.1.order_elected).unwrap()); - for (i, (winner, _)) in winners.into_iter().enumerate() { - println!("{}. {}", i + 1, winner.name); + for (i, (winner, count_card)) in winners.into_iter().enumerate() { + if let Some(kv) = &count_card.keep_value { + println!("{}. {} (kv = {:.dps2$})", i + 1, winner.name, kv, dps2=max(stv_opts.pp_decimals, 2)); + } else { + println!("{}. {}", i + 1, winner.name); + } } }