X-Git-Url: https://projects.mako.cc/source/selectricity-live/blobdiff_plain/6dfbfbec4b0d01138c272649d668c5a872706a5c..f7e185abe92cf8a4590f32996c86d15b8309db86:/lib/rubyvote/irv.rb?ds=sidebyside diff --git a/lib/rubyvote/irv.rb b/lib/rubyvote/irv.rb index 3851738..c3fabe6 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=[] + return + end + begin ranked_candidates = votes.sort do |a, b| b[1][0] <=> a[1][0]