Hi! I don't have extensive experience with sorting methods, but in this case I think a simple approach would work, like that:

use strict; use warnings; my $Line; # one input line my @SortedData; # resulting sorted data set # data set example my @Data = ( '100644:MWTP_CAT:12002: SERVER:pid=14520:Execution + time:TPR015-10:(millisec):53', '100644:MWTP_CAT:12002: SERVER:pid=15866:Execution + time:TPR015-10:(millisec):10', '100644:MWTP_CAT:12002: SERVER:pid=15866:Execution + time:TPR015-10:(millisec):33', '100644:MWTP_CAT:12002: SERVER:pid=16565:Execution + time:TPR007-12:(millisec):437', '100644:MWTP_CAT:12002: SERVER:pid=16565:Execution + time:TPR007-12:(millisec):470', '100644:MWTP_CAT:12002: SERVER:pid=16048:Execution + time:TPR009-30:(millisec):24', '100644:MWTP_CAT:12002: SERVER:pid=15866:Execution + time:TPR012-01E:(millisec):63', '100644:MWTP_CAT:12002: SERVER:pid=10427:Execution + time:ISCST044:(millisec):0', '100644:MWTP_CAT:12002: SERVER:pid=15866:Execution + time:TPR012-01E:(millisec):85', '100644:MWTP_CAT:12002: SERVER:pid=10428:Execution + time:01201E:(millisec):3', ); # create sorted data set @SortedData = reverse sort { (split (/:/, $a))[-1] <=> (split (/:/, $b +))[-1] } @Data; ### DEBUG: print input and output sets ### print "Data Set is:\n", join ("\n", @Data), "\n"; print "Sorted Data is:\n", join ("\n", @SortedData), "\n";

In reply to Re: Sorting records on a single field by Lain78
in thread Sorting records on a single field by TStanley

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, details, 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, summary, 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.