From b9c0da19d1902e103ef3ec22c2b006af4fd4fd59 Mon Sep 17 00:00:00 2001 From: vonavi Date: Sun, 6 Oct 2013 01:47:40 +0300 Subject: [PATCH] Slight changes in 'tournament_table.rb'. --- lib/lorchess/tournament_table.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/lorchess/tournament_table.rb b/lib/lorchess/tournament_table.rb index 8d6425b..76403cd 100644 --- a/lib/lorchess/tournament_table.rb +++ b/lib/lorchess/tournament_table.rb @@ -68,13 +68,13 @@ module LORChess sum = 0.0 row.each { |score| sum += score.to_f } @player_score << sum.to_s - score_data << [i, sum] + score_data << {:position => i, :total => sum} end - # Sort players in correspondence with the decrease of place - score_data.sort! { |x,y| y[1] <=> x[1] } + # Sort players in the reverse order to total score + score_data.sort! { |x,y| y[:total] <=> x[:total] } - score_data.each_with_index { |data,i| @player_place[data[0]] = (i+1).to_s } + score_data.each_with_index { |data,i| @player_place[data[:position]] = (i+1).to_s } end def stylize_table