in reply to Predefined Sort
(I'm just guessing what the order should be for port numbers that follow "554, 110, 80", since you didn't clarify that.)# seemingly arbitrary (but "meaningful") ordering sequence of port num +bers: my @port_seq = qw/554 110 80 8080 22 25 21 443 53/; # hash to deliver ordering value for each port value: my %port_order = map { $port_seq[$_] => $_ } 0 .. $#port_seq; # unordered array of data (port numbers): my @ports = qw(544 554 80 80 80 80 80 53 22 22 22 22 8080 554 443 80 8 +0 25 110 143 143 110 21 22 111 110); # print @ports in "sorted" order: print "$_\n" for ( sort {$port_order{$a} <=> $port_order{$b}} @ports ) +;
You might want the "port_seq" array to be in a config file, in case you change your mind about how the ports should be ordered (or how many/which ports are being listed).
|
|---|