in reply to Predefined Sort
I'm having a bit of trouble understanding what you want your sort criteria to be?
Near as I can tell you either want to sort in some type of reverse numeric order perhaps ignoring certain values OR you want to sort all ports in a list based on an order that you predefine.
For sorting a list based on predefined order where your predefined order is stored in an array @predefined:
If you are filtering out certain groups we'd have to stack this command with some type of grep.
Hope this helps,
Kris
Near as I can tell you either want to sort in some type of reverse numeric order perhaps ignoring certain values OR you want to sort all ports in a list based on an order that you predefine.
For sorting a list based on predefined order where your predefined order is stored in an array @predefined:
For sorting in numeric reverse order:foreach $element (@dports) { $count_hash{$element}++; } foreach $key (@predefined) { print "$key\n" x $count_hash{$key} if $count_hash{$key}; }
my @sorted = sort {$b <=> $a} @dports;
If you are filtering out certain groups we'd have to stack this command with some type of grep.
Hope this helps,
Kris
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Predefined Sort
by kyle (Abbot) on Jun 20, 2008 at 16:40 UTC | |
by Fletch (Bishop) on Jun 20, 2008 at 17:34 UTC | |
by kyle (Abbot) on Jun 20, 2008 at 17:47 UTC | |
by krusty (Hermit) on Jun 20, 2008 at 17:25 UTC | |
by kyle (Abbot) on Jun 20, 2008 at 17:36 UTC |
In Section
Seekers of Perl Wisdom