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 dae5563..3942b6b 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;