Re: Tree sort in C

From: Date: Thu, 10 May 2007 08:39:04 +0000
Subject: Re: Tree sort in C
References: 1 2 3 4 5 6 7  Groups: php.internals 
Request: Send a blank email to internals+get-29387@lists.php.net to get a copy of this message
On 09/05/07, Brian Moon <brianm@dealnews.com> 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!"

« previous php.internals (#29387) next »