If you want the port numbers to be listed in a particular order (which is different from a numeric or string sorted order), have you tried creating a hash with the port numbers as keys and the desired ordering as values? Something like this (if this is what you want):
# 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 ) +;
(I'm just guessing what the order should be for port numbers that follow "554, 110, 80", since you didn't clarify that.)

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).


In reply to Re: Predefined Sort by graff
in thread Predefined Sort by k_grdn

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.