in reply to Sorting integer value hash keys
#!/usr/bin/perl my %statistics = ( 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0 ); foreach my $statistic (sort {$a <=> $b} keys %statistics) { print $statistic ." ".$statistics{$statistic}. "\n"; } Output: 1 0 2 0 3 0 4 0 5 0 6 0 7 0 8 0 9 0 10 0
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Sorting integer value hash keys
by JadeNB (Chaplain) on Dec 25, 2009 at 18:53 UTC | |
by ikegami (Patriarch) on Dec 25, 2009 at 19:25 UTC | |
by JadeNB (Chaplain) on Dec 25, 2009 at 19:41 UTC | |
by ikegami (Patriarch) on Dec 25, 2009 at 20:01 UTC |
In Section
Seekers of Perl Wisdom