%db = (
'scores' => {
'user1' => 200,
'user2' => 190,
'user3' => 232,
'user4' => 187,
'user5' => 190
}
);
####
1st Place: user3 (232 Points)
2nd Place: user1 (200 Points)
3rd Place: user2 (190 Points)
4th Place: user5 (190 Points)
5th Place: user4 (187 Points)
####
1st Place: user3 (232 Points)
2nd Place: user1 (200 Points)
3rd Place: user2 (190 Points), user5 (190 Points)
4th Place: user4 (187 Points)
####
my @totals = sort { $db{'scores'}{$b} <=> $db{'scores'}{$a} } keys(%{$db{'scores'}});
#Right here I need something that places all the users and their scores in another hash
#This new hash would probably be a hash of arrays.
#I just can't figure it out!
#Also, these lines here should not be hardcoded!
#I do not know how many positions there are!
#Meaning I manually outputted places 1st through to 5th,
#but there might be 25 of them!
#There should be some kind of loop that does it for me
print qq|
1st Place: $totals[0]
2nd Place: $totals[1]
3rd Place: $totals[2]
4th Place: $totals[3]
5th Place: $totals[4]
|;