X-Git-Url: https://projects.mako.cc/source/selectricity-live/blobdiff_plain/0f9de7a83f46b302d82dbeb66def7f12ae15077a..58548f03d162cdb794b78aa272a7a3ebf1500f97:/lib/rubyvote/condorcet.rb diff --git a/lib/rubyvote/condorcet.rb b/lib/rubyvote/condorcet.rb index f86e59d..7fda91b 100644 --- a/lib/rubyvote/condorcet.rb +++ b/lib/rubyvote/condorcet.rb @@ -157,6 +157,7 @@ class CondorcetResult < ElectionResult def victories_and_ties victors = Array.new ties = Array.new + victories = Hash.new candidates = @matrix.keys.sort candidates.each do |candidate| @@ -170,8 +171,15 @@ class CondorcetResult < ElectionResult end end end - - victories = victors.sort {|a,b| b[2] <=> a[2]} + + victors.each do |list| + if victories.has_key?(list[0]) + victories[list[0]][list[1]] = list[2] + else + victories[list[0]] = Hash.new + victories[list[0]][list[1]] = list[2] + end + end return victories, ties end