develooper Front page | perl.fwp | Postings from July 2001

Re: Sorting in-place? (Whoops!)

Thread Previous | Thread Next
From:
merlyn
Date:
July 26, 2001 08:25
Subject:
Re: Sorting in-place? (Whoops!)
Message ID:
m1snfjbtl9.fsf@halfdome.holdit.com
>>>>> "Clinton" == Clinton A Pierce <clintp@geeksalad.org> writes:

Clinton> On Thu, Jul 26, 2001 at 10:47:05AM -0400, Clinton A . Pierce wrote:
>> for(0..20) { push(@r, int rand(50)) }

Clinton> Followup to myself, the result of this is entirely dependant on how
Clinton> the list is created.   The problem, it seems, is in the 
Clinton> 		newSViv(a>b?1:-1)
Clinton> statement.  It was a poor choice to find relative positions within the
Clinton> list.  Heh.  Sorry 'bout that.  :)

Ahh.  I was wondering about that!  So you did the equivalent of

        \$a > \$b ? 1 : -1

inside the sort function... a value we already had. :)

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

Thread Previous | Thread Next


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