develooper Front page | perl.perl5.porters | Postings from July 2004

Re: optimizing Short circuiting sort method based on [M]

From:
david nicol
Date:
July 12, 2004 19:34
Subject:
Re: optimizing Short circuiting sort method based on [M]
Message ID:
1089686084.1440.18.camel@plaza.davidnicol.com
On Mon, 2004-07-12 at 14:14, Nicholas Clark wrote:
> Gosh. It takes quite a lot of effort to contrive a test that actually
> demonstrate this. The simplest scenario I can think of is tied values.

Balderdash.

[david@plaza david]$ perl -le '@Ar = qw/5one 4one 5two 4two/; print
foreach sort {$b <=> $a} @Ar'
5two
5one
4two
4one
[david@plaza david]$ perl -le '@Ar = qw/5one 4one 5two 4two/; $default =
0; print foreach sort {$b <=> $a or $default} @Ar'
5one
5two
4one
4two




-- 
david nicol
    "People used to be able to read my thoughts, but
it doesn't appear to work any more. Should I eat less cheese?"
                                               -- Elizabeth Woods




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About