X-Git-Url: https://projects.mako.cc/source/selectricity/blobdiff_plain/6a62ba861098fb0992a12211df565b7e5dce2240..9565924bed8f9afd0682d4d029378711b905c550:/lib/rubyvote/irv.rb diff --git a/lib/rubyvote/irv.rb b/lib/rubyvote/irv.rb index 3851738..b26b1d1 100644 --- a/lib/rubyvote/irv.rb +++ b/lib/rubyvote/irv.rb @@ -87,6 +87,11 @@ class InstantRunoffResult < ElectionResult apply_retention(votes, votes_sum * params['percent_retention']) end + unless votes.length > 0 + @winners=[nil] + return + end + begin ranked_candidates = votes.sort do |a, b| b[1][0] <=> a[1][0]