From: Ian Jackson Date: Tue, 23 Aug 2016 12:46:32 +0000 (+0100) Subject: compute-scottish-stv: prep for --for-compare to list winners too (nfc) X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=appendix-a6.git;a=commitdiff_plain;h=74893eb17a71ef9a0626be1237d1a5c5b84bcadb;ds=sidebyside compute-scottish-stv: prep for --for-compare to list winners too (nfc) --- diff --git a/compute-scottish-stv b/compute-scottish-stv index 12645fd..40a6667 100755 --- a/compute-scottish-stv +++ b/compute-scottish-stv @@ -209,16 +209,18 @@ sub prf { } sub countballots () { + my @pr; + foreach my $c (values %cands) { next if $c->{NonCont}; $c->{Total} = 0/1; $c->{Total} += $_->{Weight} foreach @{ $c->{Votes} }; print DEBUG "counted $c->{Cand} $c->{Total}\n"; $c->{History}[$stage-1] = $c->{Total}; + push @pr, $c; } - foreach my $c (reverse sort $display_cmp - grep { !$_->{NonCont} } values %cands) { + foreach my $c (reverse sort $display_cmp @pr) { prf "candidate %-10s: %s votes\n", $c->{Cand}, sv $c->{Total}; } }