iwanthome has asked for the wisdom of the Perl Monks concerning the following question:
I have a hash which contain netflow statistic data. And I want to sort it by total number of packets and total size.
My code is like this:
%flows = sort {$flows{$b}{pkts} <=> $flows{$a}{pkts} or $flows{$b}{size} <=> $flows{$a}{size} } %flows;
But why not it work normal? What's wrong with it?
thanks!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to sort HASH?
by borisz (Canon) on Apr 05, 2004 at 09:18 UTC | |
by iwanthome (Beadle) on Apr 05, 2004 at 09:24 UTC | |
|
Re: How to sort HASH?
by Limbic~Region (Chancellor) on Apr 05, 2004 at 12:14 UTC | |
|
Re: How to sort HASH?
by u235sentinel (Hermit) on Apr 05, 2004 at 17:30 UTC | |
by Limbic~Region (Chancellor) on Apr 05, 2004 at 18:19 UTC | |
by u235sentinel (Hermit) on Apr 05, 2004 at 21:43 UTC |