Re: The Sort Problem

2004-02-11 Thread Uri Guttman
> "LP" == Luke Palmer <[EMAIL PROTECTED]> writes: LP> Uri Guttman writes: >> > "GNP" == Gregor N Purdy <[EMAIL PROTECTED]> writes: >> GNP> (But, the GRT doesn't apply to sorting general objects, and the GNP> example has @unsorted containing objects on which we run GNP> .foo('b

Re: The Sort Problem

2004-02-11 Thread Luke Palmer
Uri Guttman writes: > > "GNP" == Gregor N Purdy <[EMAIL PROTECTED]> writes: > > GNP> (But, the GRT doesn't apply to sorting general objects, and the > GNP> example has @unsorted containing objects on which we run > GNP> .foo('bar').compute.) > > there are no restrictions on what the GRT

Re: The Sort Problem

2004-02-11 Thread Uri Guttman
> "GNP" == Gregor N Purdy <[EMAIL PROTECTED]> writes: GNP> The Schwartzian is the usual way, of course: GNP> map { $_->[1] } GNP> sort { $^a[0] <=> $^b[0] } GNP> map { [ $_.foo('bar').compute, $_ ] } GNP> @unsorted; and the GRT is another. let stick my nose in here. sorti

Re: [perl] The Sort Problem

2004-02-11 Thread Joe Gottman
- Original Message - From: "Luke Palmer" <[EMAIL PROTECTED]> To: "Language List" <[EMAIL PROTECTED]> Sent: Wednesday, February 11, 2004 10:11 PM Subject: [perl] The Sort Problem > I've been thinking about this problem which comes up in my code a lot: > > @sorted = sort { $^a.foo('ba

Re: The Sort Problem

2004-02-11 Thread Gregor N. Purdy
Luke -- Hmmm... I haven't been practicing my Perl 6, and its been a while since the last Apocalyptic refresher, but here goes (I'll don a paper bag preemptively)... Thinking of that as the equivalent to: sort { my ($ta, $tb) = map { $_.foo('bar').compute } ($^a, $^b); $ta <=> $tb } @

The Sort Problem

2004-02-11 Thread Luke Palmer
I've been thinking about this problem which comes up in my code a lot: @sorted = sort { $^a.foo('bar').compute <=> $^b.foo('bar').compute } @unsorted; Often the expressions on each side are even longer than that. But one thing remains: both sides are exactly the same, substi