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

Re: more 5.9 sort tests

From:
Nicholas Clark
Date:
July 21, 2004 06:12
Subject:
Re: more 5.9 sort tests
Message ID:
20040721131219.GT784@plum.flirble.org
On Wed, Jul 21, 2004 at 02:37:35PM +0200, Rafael Garcia-Suarez wrote:
> david nicol wrote:
> > @@ -577,6 +577,13 @@
> >  @input = sort {$b <=> $a} @input;
> >  ok "@input", "G H I D E F A B C", 'stable $b <=> $a in place sort';
> >  
> > +# test that optimized {$b cmp $a} remains stable (new in 5.9)
> > +# without overloading
> > +@b = sort { $b <=> $a } @input = qw/5first 6first 5second 6second/;
> 
> I assume you meant "cmp" instead of "<=>" here ?

Based on my memory of the thread David figured a way to test sort stability
without resorting to overloading, by using <=> and not-really-numbers
rather than the complex overloading games I thought of.

However, the patch isn't warnings clean, which given that sort.t runs under
warnings, isn't going to fly.

Nicholas Clark



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