Reputation: 107
I have a calendar filled with daily hours from persons. I like to sort my hours per day.. i already counted the hours.
loop....
# $daguren 1..31
# uren = sum of all the daily hours
$daguren{$dag} += $workedhours;
...loop
# i like to sort it on "daguren" that is a number 1 .. 31
while (($dag,$uren)=each %daguren){
print "dag=$dag uren=$uren<br>\n";
}
Upvotes: -1
Views: 82
Reputation: 5082
You want to iterate over the keys
# This sorts by working hours
my @sorted_keys = sort { $daguren{$a} <=> $daguren{$b} } keys %daguren;
# This sorts by date
my @sorted_keys = sort { $a <=> $b } keys %daguren;
foreach my $dag ( @sorted_keys )
{
my $uren = $daguren{$dag};
print "dag=$dag uren=$uren<br>\n";
}
Upvotes: 4