At 10:50 AM 3/26/2001 -0500, Uri Guttman wrote:
> >>>>> "SC" == Simon Cozens <[EMAIL PROTECTED]> writes:
>
> SC> Why can't Perl automagically do a Schwartzian when it sees a
> SC> comparison with complicated operators or functions on each side of
> SC> it? That is, @s = sort { f($a) <=> f($b) } @t would Do The Right
> SC> Thing.
>
>because that would require the PSI::ESP module which isn't working
>yet. how would perl intuit exactly the relationship between the records
>and the keys extraction and comparison?
I'm kinda puzzled by the focus on Schwartzian when I thought the GRT was
demonstrated to be better. Anyway, all we need is a syntax for specifying
an extraction function and whether the comparison is string or numeric. If
the parser can be persuaded to accept an array ref instead of a block, how
about
sort [ '<=>' => \&f ] @t
doing The Right Thing? I guess you could also pragmatize it if you wanted
a particular transform:
use sort qw(schwartzian);
Someone could probably turn this into "use the schwartz".