OSDN Git Service

Sort by last_modified for not-yet-rated players.
authorbeatles <beatles@b8c68f68-1e22-0410-b08e-880e1f8202b4>
Tue, 5 Feb 2008 13:24:37 +0000 (13:24 +0000)
committerbeatles <beatles@b8c68f68-1e22-0410-b08e-880e1f8202b4>
Tue, 5 Feb 2008 13:24:37 +0000 (13:24 +0000)
mk_html

diff --git a/mk_html b/mk_html
index d8c6c53..5e75f26 100755 (executable)
--- a/mk_html
+++ b/mk_html
@@ -60,7 +60,15 @@ def main
   popup_id = 0
 
   file["players"].sort.each do |key, yaml| # sort groups in the order written in players.yaml
-  sorted_keys = yaml.keys.sort {|a,b| yaml[b]['rate'] <=> yaml[a]['rate']} # sort players in a group by one's rate
+  sorted_keys = yaml.keys.sort do |a,b| 
+    # sort players in a group by one's rate
+    if yaml[b]['rate'] == 0 && yaml[a]['rate'] == 0
+      # mainly for not-rated-yet players
+      yaml[b]['last_modified'] <=> yaml[a]['last_modified']
+    else
+      yaml[b]['rate'] <=> yaml[a]['rate']
+    end
+  end 
   top_rate = nil  
   table = ERB.new(<<ENDTABLE, nil, "%>")
 % sorted_keys.each do |key|