Greetings, Never mind. Got the following to work OK:
my $sorter = &Sort::Maker::make_sorter(qw(ref_in ref_out),
qw(ST),
number => '/(\d+\.\d+)/',
'descending',
'unsigned_float',
)
or die "Can't make sorter [EMAIL PROTECTED]";
it produces the following sort:
sub {
return [
map $_->[0],
sort {
$b->[1] <=> $a->[1]
}
map [ $_,
do{ my ($val) = /(\d+\.\d+)/ ; $val }
], @{$_[0]} ] ;
}
Sorry to have troubled the list
Not sure why code => didn't work.
Thank you,
John Kent
-----Original Message-----
From: Kent, Mr. John (Contractor)
Sent: Wednesday, April 05, 2006 9:35 AM
To: Beginning Perl; Uri Guttman (E-mail)
Cc: Kent, Mr. John (Contractor)
Subject: Using Sort::Maker
Greetings,
I'm having some trouble using Sort::Maker and was hoping
someone could assist.
I have very large arrays of file names that look like:
my @ARRAY = qw{
20060312.1230.goes10.ir.x.pacus.x.jpg
20060324.1500.goes10.ir.x.pacus.x.jpg
20060405.0000.goes10.ir.x.pacus.x.jpg
20060312.1300.goes10.ir.x.pacus.x.jpg
20060324.1530.goes10.ir.x.pacus.x.jpg
20060405.0030.goes10.ir.x.pacus.x.jpg
20060312.1330.goes10.ir.x.pacus.x.jpg
}
The following code works fine and produces a ST $sorter without problem:
Very Cool!!
#!/usr/local/bin/perl (5.8.8)
use Sort::Maker ;
my $sorter = &Sort::Maker::make_sorter(qw(ref_in ref_out),
qw(ST),
number,
'descending',
'unsigned_float',
)
or die "Can't make sorter [EMAIL PROTECTED]";
#To see the output:
my $sorted_array = $sorter->([EMAIL PROTECTED]);
print "Raw sort results\n";
foreach (@{$sorted_array}){
print "$_\n";
}
------------------------------------------------------------------------
-------------------------------------
So what's the problem?
The following sort which is taken directly from the documentation
does NOT work:
my $sorter = &Sort::Maker::make_sorter(qw(ref_in ref_out),
qw(ST),
number => [
qw(descending unsigned_float),
code => '/(\d+)/',
],
)
or die "Can't make sorter [EMAIL PROTECTED]";
And produces the following error:
Can't make sorter make_sorter: Unknown attribute '/(\d+)/'
Would like to get this second sort to work,
because I want to sort on the entire float number
not just the integer: '/(\d+\.\d+)/'
Thank you,
John Kent
Webmaster NRL Monterey,
http://www.nrlmry.navy.mil
smime.p7s
Description: S/MIME cryptographic signature
