Steny has asked for the wisdom of the Perl Monks concerning the following question:
my %bnb = {Seals => 0, Fighters => 0, Panzers => 0, 'Heavy Lasers' => +0, Marines => 0, Bombers => 0}; my $bestNw; foreach my $key (sort { $bnb{$a} <=> $bnb{$b} } keys %bnb) { if ($bnb{$key} > 0) { my $value = addComma($bnb{$key}); push @$bestNw, { unit => $key, value => $value }; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem sorting hash & assigning to new hash to send to HTML::Template
by borisz (Canon) on Jun 06, 2004 at 21:14 UTC | |
|
Re: Problem sorting hash & assigning to new hash to send to HTML::Template
by neniro (Priest) on Jun 06, 2004 at 21:18 UTC | |
|
Re: Problem sorting hash & assigning to new hash to send to HTML::Template
by bradcathey (Prior) on Jun 06, 2004 at 20:37 UTC | |
|
Re: Problem sorting hash & assigning to new hash to send to HTML::Template
by eric256 (Parson) on Jun 07, 2004 at 06:09 UTC |