From: John Dong Date: Wed, 15 Aug 2007 19:53:05 +0000 (+0000) Subject: Add similar hackish "fix" for IRVL deadlocking on empty vote X-Git-Url: https://projects.mako.cc/source/rubyvote/commitdiff_plain/9953cb5cdef82f0e44f07dd089fde77ede170712?ds=sidebyside;hp=0e05e46d80413a70fc4aa10bfabbbac048add5a8 Add similar hackish "fix" for IRVL deadlocking on empty vote git-svn-id: svn://rubyforge.org/var/svn/rubyvote/trunk@35 1440c7f4-e209-0410-9a04-881b5eb134a8 --- 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]