Re: plperl & sort - Mailing list pgsql-bugs

From Jeff
Subject Re: plperl & sort
Date
Msg-id 0398C703-6CF4-438A-810D-ACDBDAA7A146@torgo.978.org
Whole thread Raw
In response to Re: plperl & sort  (Andrew Dunstan <andrew@dunslane.net>)
List pgsql-bugs
On Nov 4, 2008, at 4:43 PM, Andrew Dunstan wrote:

>
> OK, the first thing to note is that there is an easy workaround,
> which is to use a sort routine that doesn't need $a/$b. Example:
>
>   create or replace function mysort() returns text language plperl
> as $f$
>
>       my $sfunc = sub ($$) { $_[0] <=> $_[1] };
>
>       my @vals = (5,3,4,2,7);
>
>       return join(' ',sort $sfunc @vals);
>
>   $f$;
>

Andrew for the win!

Thanks a lot!

I agree, a documentation note would be fine for this rather doing all
sorts of complicated perl trickery.

--
Jeff Trout <jeff@jefftrout.com>
http://www.stuarthamm.net/
http://www.dellsmartexitin.com/

pgsql-bugs by date:

Previous
From: "Hiroshi Saito"
Date:
Subject: Re: [ODBC] Behavior change of FK info query
Next
From: Tom Lane
Date:
Subject: Re: BUG #4510: memory leak with libpg.dll