in reply to Fixed 'Top 10' compared with visitors' Top 10
Of course, TMTOWTDI, as usual.%songs = ( 'Insomina' => { 'sales' => '9999', 'votes' => '1' }, 'Enter Sandman' => { 'sales' => '9998', 'votes' => '10' }, 'Bad Moon Rising' => { 'sales' => '9997', 'votes' => '9' } ); sub bysales { $songs{$b}{sales} <=> $songs{$a}{sales}; } sub byvotes { $songs{$b}{votes} <=> $songs{$a}{votes}; } # Print the best songs by sales foreach $ditty ( sort bysales keys songs ) { print "$ditty\n"; } # Print the best songs by votes foreach $ditty ( sort byvotes keys songs ) { print "$ditty\n";
|
|---|