Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:29387 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 98835 invoked by uid 1010); 10 May 2007 08:39:16 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 98820 invoked from network); 10 May 2007 08:39:16 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 May 2007 08:39:16 -0000 Authentication-Results: pb1.pair.com smtp.mail=rquadling@googlemail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rquadling@googlemail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain googlemail.com designates 64.233.184.234 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: rquadling@googlemail.com X-Host-Fingerprint: 64.233.184.234 wr-out-0506.google.com Linux 2.4/2.6 Received: from [64.233.184.234] ([64.233.184.234:43603] helo=wr-out-0506.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9A/17-20961-F2AD2464 for ; Thu, 10 May 2007 04:39:14 -0400 Received: by wr-out-0506.google.com with SMTP id i21so547143wra for ; Thu, 10 May 2007 01:39:06 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=googlemail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=rkH2yGaweyiTpNEG+a1gODeW2j/N4/OKMSAnJbXNrQ0xM7s3pCcu4ePKLrYxezUwD5vQhxNGCpNR/Jic+248TyHcshOyv3CkLcNpaJOaRBhoJFkO63OTxV/D3IGZ4XYR7QMAIxecGIlLJAMTmH4jrQVfsjrbaXA8qB88q+ESbOA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=beta; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=nbqnu3q7sOfLsTRx0xvWXBm8UHQALYjhh4DKbMCbS7eulTr7WODRsh3hR3wxehZEq1OivonmPAUAoprNeJURHovuU2LwuUaDJSNStDFHxu1CMw+Q8zSQPbBHbh1IbjqEQ4fL2VAugb6PjWE2hHyQqvt1AB7OR7YVp37Ma6412ss= Received: by 10.78.162.4 with SMTP id k4mr323765hue.1178786345397; Thu, 10 May 2007 01:39:05 -0700 (PDT) Received: by 10.78.48.15 with HTTP; Thu, 10 May 2007 01:39:04 -0700 (PDT) Message-ID: <10845a340705100139t7d3b4859vd9b405b6147d5e02@mail.gmail.com> Date: Thu, 10 May 2007 09:39:04 +0100 Reply-To: RQuadling@GoogleMail.com To: "Brian Moon" Cc: "Derick Rethans" , "Maurice Makaay" , "Michael Walter" , internals@lists.php.net In-Reply-To: <46420846.8020502@dealnews.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <4641D92C.4050208@dealnews.com> <10845a340705090743v6aba7896y45b9f7d60a4e77ba@mail.gmail.com> <4641E3DD.8040807@phorum.org> <877e9a170705090913i320359cag81b0a3bf203e2c86@mail.gmail.com> <464202D9.8080509@phorum.org> <46420846.8020502@dealnews.com> Subject: Re: [PHP-DEV] Tree sort in C From: rquadling@googlemail.com ("Richard Quadling") On 09/05/07, Brian Moon wrote: > Derick Rethans wrote: > > On Wed, 9 May 2007, Maurice Makaay wrote: > > > >> At a really > >> large number of nodes, the extension becomes slower, but the memory stays low. > > > > That is very peculiar... it should never be slower than an > > implementation in PHP - unless your algorithm isn't optimal. > > Me too. But, fwiw, the multisort method does not do the same thing. > So, its apples to oranges. See my other email. In the apples to apples > comparisons with use the same algorithm in PHP and in C, the C version > is always faster. > I agree with Brian here, the code I referenced was an array multisort by column which I created based upon user notes on the array_multisort function. You do not require a trawl through to get the list of "keys" like is done here. So, $sorted = array_multisort_column($nodes, 'parent_id', 'id'); It is a single pass mechanism. It uses the indexes supplied to compare them in sequence. A simple bubble sort. BUT this is not a tree sort as this is something quite different. The array_multisort() nor my array_multisort_column() functions will not work for more than 1 level of parent/child relationships. Richard > -- > > Brian Moon > Senior Developer > ------------------------------ > http://dealnews.com/ > It's good to be cheap =) > -- ----- Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 "Standing on the shoulders of some very clever giants!"