On Thu, 2004-02-12 at 01:59, Uri Guttman wrote: > sorry about the confusion. read the paper at: > > http://www.sysarch.com/perl/sort_paper.html
All of which stops being a concern if you have a sort variant that works
on pairs in the first place. Perl _5_ code follows:
sub sortpairs(&@) {
my $comp = shift;
my %pairs = @_;
return map {$pairs{$_}} sort {$comp->($a)} keys %pairs;
}
@new1 = sortpairs {$a <=> $b} map {($_->computekey,$_)} @old1;
@new2 = sortpairs {$a cmp $b} map {(lc($_),uc($_))} @old2;
as you can see, you can perform any key extraction you like in the map
portion (which just returns key/value pairs) and sortpairs' job is just
to compare the keys and return the resulting sorted values.
No Perl 6 here, move along ;-)
Perl 6 could contribute here by making it cheaper to construct/pass the
keys, but that's about it.
--
Aaron Sherman <[EMAIL PROTECTED]>
Senior Systems Engineer and Toolsmith
"It's the sound of a satellite saying, 'get me down!'" -Shriekback
signature.asc
Description: This is a digitally signed message part
