in reply to Using a hash for an ordered set can make sense
This is an erroneous application of the ST. The ST should be used only when the ordering function is expensive for each element. Hash lookup is not expensive. I'd rewrite this as a simple defined sort:print "$_\n" ofr map { $_->[0] } sort { $a->[1] <=> $b->[1] } map { [ $_, $hash{$_} ] } keys %hash;
Easier to type, faster, and clearer. The trifecta!print "$_\n" for sort { $hash{$a} <=> $hash{$b} } keys %hash;
-- Randal L. Schwartz, Perl hacker
|
---|