Sorting the list returned by %hash is quite wrong.
use strict; use warnings; my %hash = map { $_ => 1 } qw( foo food dood ); my @svalues1 = @hash{ sort { $a=~tr/d// <=> $b=~tr/d// } keys %hash }; my @svalues2 = @hash{ sort { $a=~tr/d// <=> $b=~tr/d// } %hash }; print(0+@svalues1, "\n"); # 3 print(0+@svalues2, "\n"); # 6
In reply to Re^2: Sorting a hash in one line
by ikegami
in thread Sorting a hash in one line
by rachitmohta11
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |