aboutsummaryrefslogtreecommitdiff
path: root/poll.rb
diff options
context:
space:
mode:
authorBenjamin Kellermann <Benjamin.Kellermann@gmx.de>2008-11-09 09:34:13 +0100
committerBenjamin Kellermann <Benjamin.Kellermann@gmx.de>2008-11-09 09:34:13 +0100
commita6d1e73b94272caffb411b050c51029f51fc7602 (patch)
tree9ce3a2de69a4765eb33c8a5e98e86b7e12f97771 /poll.rb
parentfc18c43ad3b324ae46c392b5a6da0e5f9c9637c6 (diff)
bugfix: sort didn't worked correct
Diffstat (limited to 'poll.rb')
-rw-r--r--poll.rb19
1 files changed, 9 insertions, 10 deletions
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 = "<tr><th><a href='?sort=name'>Name</a></th>\n"
@@ -38,7 +38,6 @@ class Poll
ret += "<table border='1'>\n"
ret += head_to_html
-
sort_data($cgi.include?("sort") ? $cgi.params["sort"] : ["timestamp"]).each{|participant,poll|
ret += "<tr>\n"
ret += "<td class='name'>#{participant}</td>\n"