http://www.perlmonks.org?node_id=341219

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Monks
Could you please tell me why this code is not sorting my values?
$totalscoreinv{$key1}{key2}= $totalscore; foreach $keyscore (sort by_score keys %totalscoreinv){ print OUT "\n\n $keyscore\n"; foreach my $keyscore2 (keys %{$totalscoreinv{$keyscore}}){ printf(OUT "%30s %s\n", "$keyscore2= ", "$totalscoreinv{$keyscore} +{$keyscore2}"); } } sub by_score { $totalscorepass{$keyscore}{$b}<=>$totalscorepass{$keyscore}{$a}; }
One more question, once is sorted, how I can get/display/or compare with only the best(first) value by each outer-key?
Thanks