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";
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.