From 2aa93aa5ac38fdc368e44763e6aa12b8c2a49481 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sun, 25 Mar 2012 19:28:02 +0200 Subject: [PATCH] Sort players when writing them to file, to be consistent with the ordering the JavaScript sees. --- www/index.pl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/www/index.pl b/www/index.pl index fd3228b..50bf051 100755 --- a/www/index.pl +++ b/www/index.pl @@ -177,6 +177,10 @@ sub get_covariance_matrix { sub write_parms_to_file { my ($aux_parms, $match_stddev, $used_ratings, $used_cov) = @_; + POSIX::setlocale(&POSIX::LC_ALL, 'nb_NO.UTF-8'); + + my @sorted_players = sort { $players{$a} cmp $players{$b} } keys %players; + POSIX::setlocale(&POSIX::LC_ALL, 'C'); my $tmpnam = POSIX::tmpnam(); @@ -186,7 +190,7 @@ sub write_parms_to_file { printf MCCALC "%f\n", $match_stddev; printf MCCALC "%d\n", scalar keys %players; - for my $id (keys %players) { + for my $id (@sorted_players) { my $rating = $used_ratings->{$id} // 500.0; printf MCCALC "%s %f\n", $id, $rating; } -- 2.39.2