chiark
/
gitweb
/
~ian
/
appendix-a6.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
compute-scottish-stv: --sort=alpha
[appendix-a6.git]
/
compute-scottish-stv
diff --git
a/compute-scottish-stv
b/compute-scottish-stv
index 47604073388b5a14acc81a847ea9142e2ca05a2b..81dc6adeafb10d553c50b2153a250a530bfc8966 100755
(executable)
--- a/
compute-scottish-stv
+++ b/
compute-scottish-stv
@@
-58,6
+58,8
@@
$SIG{__DIE__} = sub {
die $_[0];
};
die $_[0];
};
+sub total_history_cmp ();
+
sub unkopt ($$) {
my ($what,$opt) = @_;
if ($opt =~ m/^[A-Z]/) {
sub unkopt ($$) {
my ($what,$opt) = @_;
if ($opt =~ m/^[A-Z]/) {
@@
-67,6
+69,19
@@
sub unkopt ($$) {
}
}
}
}
+my $display_cmp = \&total_history_cmp;
+
+while (@ARGV && $ARGV[0] =~ m/^\-/) {
+ $_ = shift @ARGV;
+ if (m/^--$/) {
+ last;
+ } elsif (m/^--sort=alpha$/) {
+ $display_cmp = sub { $b->{Cand} cmp $a->{Cand} };
+ } else {
+ die;
+ }
+}
+
for (;;) {
$_ = <>;
if (m/^\| /) {
for (;;) {
$_ = <>;
if (m/^\| /) {
@@
-198,7
+213,7
@@
sub countballots () {
$c->{History}[$stage-1] = $c->{Total};
}
$c->{History}[$stage-1] = $c->{Total};
}
- foreach my $c (reverse sort
total_histor
y_cmp
+ foreach my $c (reverse sort
$displa
y_cmp
grep { !$_->{NonCont} } values %cands) {
prf "candidate %-10s: %s votes\n", $c->{Cand}, sv $c->{Total};
}
grep { !$_->{NonCont} } values %cands) {
prf "candidate %-10s: %s votes\n", $c->{Cand}, sv $c->{Total};
}