diff options
author | Benjamin Kellermann <Benjamin.Kellermann@gmx.de> | 2008-11-09 09:34:13 +0100 |
---|---|---|
committer | Benjamin Kellermann <Benjamin.Kellermann@gmx.de> | 2008-11-09 09:34:13 +0100 |
commit | a6d1e73b94272caffb411b050c51029f51fc7602 (patch) | |
tree | 9ce3a2de69a4765eb33c8a5e98e86b7e12f97771 | |
parent | fc18c43ad3b324ae46c392b5a6da0e5f9c9637c6 (diff) |
bugfix: sort didn't worked correct
Diffstat (limited to '')
-rw-r--r-- | poll.rb | 19 |
1 files changed, 9 insertions, 10 deletions
@@ -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" |