]> git.sesse.net Git - wloh/commitdiff
Sort players when writing them to file, to be consistent with the ordering the JavaSc...
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 25 Mar 2012 17:28:02 +0000 (19:28 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 25 Mar 2012 17:28:02 +0000 (19:28 +0200)
www/index.pl

index fd3228b7a3894676b1247e19024c9fe2350af079..50bf05156cef452763d5933aba615a19835fba18 100755 (executable)
@@ -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;
        }