Re: bubble sort crashing apache

From: Date: Wed, 17 Nov 2004 09:12:16 +0000
Subject: Re: bubble sort crashing apache
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-202279@lists.php.net to get a copy of this message
Josh Howe wrote:
function that is crashing apache.
Seems soo unlikely. What do you mean exactly by this? PHP doing infinte loop?
private function sort() {
Why not simply use the std sort function? Dont reinvent the wheel http://www.php.net/manual/en/function.sort.php
if ($val2 > $val1) return true; else return false;
With bools, simply use return $val2 > $val1;
if ($this->order_dir == "desc") { if ($val2 > $val1) return true; else return false; } else { if ($val1 > $val2) return true; else return false; }
Can be simply written like this (I think it's more readable) return ($this->order_dir == "desc") ? $val2 > $val1 : $val1 > $val2 Christophe

« previous php.general (#202279) next »