]> projects.mako.cc - selectricity-live/blobdiff - lib/rubyvote/condorcet.rb
Check in a bit of partial work on controller testcases, but I'm calling it a day...
[selectricity-live] / lib / rubyvote / condorcet.rb
index f86e59d1295cdc876b9d9f380892452c5f3bab04..7fda91b48073a0308c8040ddba03ac13d8822929 100644 (file)
@@ -157,6 +157,7 @@ class CondorcetResult < ElectionResult
   def victories_and_ties
     victors = Array.new
     ties = Array.new
   def victories_and_ties
     victors = Array.new
     ties = Array.new
+    victories = Hash.new
     candidates = @matrix.keys.sort
     
     candidates.each do |candidate|
     candidates = @matrix.keys.sort
     
     candidates.each do |candidate|
@@ -170,8 +171,15 @@ class CondorcetResult < ElectionResult
         end
       end
     end
         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
     
     return victories, ties    
   end

Benjamin Mako Hill || Want to submit a patch?