[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] File::Sort



Chris Nandor writes:
|And this module really makes me wish I could pass a coderef to sort(); that
|would make it much easier to incorporate different ordering schemes.  Any
|thoughts on that?

You can sort of already do that:

sub subname { a$ cmp $b};
$r = 'subname';
sort $r @array;

or:

$r = sub { $a cmp $b };
sort {&$r} @array;

Although it would be handy in certain circumstances, and probably faster,
to be able to say:

$r = sub {...};
sort $r @array;
grep $r @array;
map $r @array;

(and $r = 'subname'; grep $r @array; map $r @array;)

Brian

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch