From a6d1e73b94272caffb411b050c51029f51fc7602 Mon Sep 17 00:00:00 2001 From: Benjamin Kellermann Date: Sun, 9 Nov 2008 09:34:13 +0100 Subject: bugfix: sort didn't worked correct --- poll.rb | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'poll.rb') diff --git a/poll.rb b/poll.rb index f045cf8..676ee18 100644 --- a/poll.rb +++ b/poll.rb @@ -12,16 +12,16 @@ class Poll store "Poll #{name} created" end def sort_data fields - @data.sort{|x,y| - if fields.include?("name") - until fields.pop == "name" - end - cmp = x[1].compare_by_values(y[1],fields) == 0 - return cmp == 0 ? x[0] <=> y[0] : cmp - else - return x[1].compare_by_values(y[1],fields) + if fields.include?("name") + until fields.pop == "name" end - } + @data.sort{|x,y| + cmp = x[1].compare_by_values(y[1],fields) + cmp == 0 ? x[0] <=> y[0] : cmp + } + else + @data.sort{|x,y| x[1].compare_by_values(y[1],fields) } + end end def head_to_html ret = "Name\n" @@ -38,7 +38,6 @@ class Poll ret += "\n" ret += head_to_html - sort_data($cgi.include?("sort") ? $cgi.params["sort"] : ["timestamp"]).each{|participant,poll| ret += "\n" ret += "\n" -- cgit v1.2.3
#{participant}