Message from discussion
The Sort Problem
Newsgroups: perl.perl6.language
Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.stanford.edu!nntp.perl.org
Return-Path: <u...@stemsystems.com>
Mailing-List: contact perl6-language-h...@perl.org; run by ezmlm
Delivered-To: mailing list perl6-langu...@perl.org
Received: (qmail 24165 invoked by uid 76); 14 Feb 2004 21:24:06 -0000
Received: from x1.develooper.com (HELO x1.develooper.com) (63.251.223.170) by onion.perl.org (qpsmtpd/0.26) with SMTP; Sat, 14 Feb 2004 13:24:06 -0800
Received: (qmail 26010 invoked by uid 225); 14 Feb 2004 21:24:02 -0000
Delivered-To: perl6-langu...@perl.org
Received: (qmail 26003 invoked by alias); 14 Feb 2004 21:24:02 -0000
Received: from [204.127.198.35] (HELO rwcrmhc11.comcast.net) (204.127.198.35) by la.mx.develooper.com (qpsmtpd/0.27-dev) with ESMTP; Sat, 14 Feb 2004 13:24:02 -0800
Received: from stemsystems.com (h00045a211c08.ne.client2.attbi.com[24.128.26.236]) by comcast.net (rwcrmhc11) with SMTP id <20040214212400013007n1mse>; Sat, 14 Feb 2004 21:24:00 +0000
Received: (qmail 1982 invoked by uid 100); 14 Feb 2004 21:17:18 -0000
To: Austin_Hasti...@yahoo.com
Cc: Rod Adams <r...@rodadams.net>, Perl 6 Language <perl6-langu...@perl.org>
Subject: Re: The Sort Problem
Date: Sat, 14 Feb 2004 16:17:18 -0500
In-Reply-To: <20040214204522.16933.qmail@web12301.mail.yahoo.com> (Austin Hastings's message of "Sat, 14 Feb 2004 12:45:22 -0800 (PST)")
Message-ID: <x77jypbbtt.fsf@mail.sysarch.com>
User-Agent: Gnus/5.090015 (Oort Gnus v0.15) Emacs/21.2
References: <20040214204522.16933.qmail@web12301.mail.yahoo.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on x1.develooper.com
X-Spam-Status: No, hits=-4.8 required=8.0 tests=BAYES_00,RCVD_IN_SORBS autolearn=no version=2.63
X-SMTPD: qpsmtpd/0.26, http://develooper.com/code/qpsmtpd/
Approved: n...@nntp.perl.org
From: u...@stemsystems.com (Uri Guttman)
>>>>> "AH" == Austin Hastings <austin_hasti...@yahoo.com> writes:
AH> --- Uri Guttman <u...@stemsystems.com> wrote:
>> @out = sort
>> key:compare( \&my_compare_sub ) ( /(\d+)$/ ),
>> @in ;
>> note that the custome compare callbacks can be a block or a sub
>> name/ref. the callback sub would be passed 2 args as usual.
AH> Off the top of my head, I can't think of a case where the compare sub
AH> would be needed unless the key was not well-ordered. Does anyone have
AH> an example of a case where the key-extraction sub approach doesn't
AH> reduce the problem to a Scalar comparison?
there are rare times when you need a computed comparison, say with a
specialized collation sequence. if this sequence isn't supported by
locale or whatever, you need to do a callback comparison. i can't think
of a real world example but maybe with some odd symbolic character set
or a custom one. in any case, supporting the callback is easy. it has
one drawback which is that it disallows the GRT but the guts could
fallback to the ST then. in both cases, key extraction is the same.
uri
--
Uri Guttman ------ u...@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org