in reply to Re: Sort Hash of Hash numerically
in thread Sort Hash of Hash numerically
Is reverse sort optimized away (it would be cool if it swapped the meaning of $a and $b) or do you really mean:
for (sort { $HoH{$b}{head_count} <=> $HoH{$a}{head_count} } keys %HoH) + { print "$_ House Type: $HoH{$_}{house_type} Head Count: $HoH{$_}{he +ad_count}\n"; }
Update: toolic++. I went searching for the definition of "newer perls" and found that this optimization has been around for some time. From perl586delta:
reverse sort ... is now optimized to sort in reverse, avoiding the generation of a temporary intermediate list.
for (reverse @foo) now iterates in reverse, avoiding the generation of a temporary reversed list.
Good Day,
Dean
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Sort Hash of Hash numerically
by toolic (Bishop) on Jun 13, 2011 at 14:50 UTC |