From: Steinar H. Gunderson Date: Sun, 25 Mar 2012 17:28:02 +0000 (+0200) Subject: Sort players when writing them to file, to be consistent with the ordering the JavaSc... X-Git-Url: https://git.sesse.net/?p=wloh;a=commitdiff_plain;h=2aa93aa5ac38fdc368e44763e6aa12b8c2a49481 Sort players when writing them to file, to be consistent with the ordering the JavaScript sees. --- 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; }