KeziaKristina
Programmer
I have source code something like this :
%HoA = (
'$b' => ['$x','$y'],
'$x' => ['$t','$u'],
'$a' => ['$e','$f','$g'],
);
#sort hash by the number of elemens
for $family ( sort { @{$HoA{$b}} <=> @{$HoA{$a}} } keys %HoA )
{
print "$family: @{ $HoA{$family} }\n";
}
print "After sorting : ";
for $family (keys %HoA ) {
print "$family: @{ $HoA{$family} }\n"
}
my question is :
Why after sorting process, the elemen of hash still the same like before sorting?
%HoA = (
'$b' => ['$x','$y'],
'$x' => ['$t','$u'],
'$a' => ['$e','$f','$g'],
);
#sort hash by the number of elemens
for $family ( sort { @{$HoA{$b}} <=> @{$HoA{$a}} } keys %HoA )
{
print "$family: @{ $HoA{$family} }\n";
}
print "After sorting : ";
for $family (keys %HoA ) {
print "$family: @{ $HoA{$family} }\n"
}
my question is :
Why after sorting process, the elemen of hash still the same like before sorting?