[EMAIL PROTECTED] wrote:
> Hi Guys,
>       I have an array of values. How can I sort these values that has
> a non numeric character [ _ ] in it? What I did was parse the numbers
> before the "_" character and then perform a number short on those
> value, but there must be an easier way? Any help is greatly
> appreciated. 
> 
> 55_20051202
> 56_20051203
> 57_20051204
> 101_20051205
> 59_20051206
> 10_20051207
> 61_20051208
> 62_20051208
> 63_20051208
> 64_20051209
> 65_20051209
> 66_20051210
> 67_20051211
> 68_20051212
> 69_20051213
> 70_20051214
One approach( Sorts by Date first aand then by the first set of digits ):
#!perl

use strict;
use warnings;

foreach my $MyData ( sort { $a->[2] <=> $b->[2] ||
                            $a->[1] <=> $b->[1]
                           }
                     map{[$_, split(/\D/, $_)]}
                     <DATA>
                    ) {
    print $MyData->[0];
 }
 
__DATA__
55_20051202
56_20051203
57_20051204
101_20051205
59_20051206
10_20051207
61_20051208
62_20051208
63_20051208
64_20051209
65_20051209
66_20051210
67_20051211
68_20051212
69_20051213
70_20051214

Output:
55_20051202
56_20051203
57_20051204
101_20051205
59_20051206
10_20051207
61_20051208
62_20051208
63_20051208
64_20051209
65_20051209
66_20051210
67_20051211
68_20051212
69_20051213
70_20051214


*******************************************************
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.
*******************************************************


_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to