chiark / gitweb /
stv: fix historically_prefer
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 1 Aug 2016 16:09:52 +0000 (17:09 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 1 Aug 2016 16:09:52 +0000 (17:09 +0100)
stv

diff --git a/stv b/stv
index dae5563dd79bfd6a46474a7c3e08a61d0b385d51..3942b6b175f488c6dbbedfd6338ded2560eb450c 100755 (executable)
--- a/stv
+++ b/stv
@@ -106,13 +106,14 @@ sub historically_prefer ($@) {
        return 0;
     };
 
-    @choices = sort $compare, @choices;
+    @choices = sort $compare @choices;
     $a = $choices[0];
-    my $numequal = 0;
+    my $numequal = 1;
     for (;;) {
-       last unless $numequal >= @choices;
+       last if $numequal >= @choices;
        $b = $choices[$numequal];
        last if $compare->();
+       $numequal++;
     }
 
     die 'random choice unimplemented' if $numequal > 1;