- or download this
# tie HASH, 'Tie::SortHash', ANON_HASH, SORT_EXPR
...
$d =~ s/\w+\s//;
$c cmp $d || $hash{$b} <=> $hash{$
+a}
);
- or download this
print "$_\t$hash{$_}\n" foreach keys %hash;
<code>
...
Jim Baker 30
Jane Doe 39
John Doe 20
- or download this
foreach ( sort keys %hash ) {
...
}
- or download this
(tied %hash)->newsortblock( q($b cmp $a) );
- or download this
my %people = (
'John Doe' => 25,
...
);
tie %people, 'Tie::SortHash', { %people }, $sortblock;