Re: array sort

From: Date: Tue, 22 May 2001 14:55:56 +0000
Subject: Re: array sort
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-53863@lists.php.net to get a copy of this message
On Mon, May 21, 2001 at 06:05:49PM -0700, Alex Black wrote : > > Use 'uasort()': > > > > function my_hash_sort( $a, $b) { > > $a = $a['num']; > > $b = $b['num']; > > if( $a == $b) return 0; > > return ( $a > $b) ? -1 : 1; > > } > > > > uasort( $test, 'my_hash_sort'); > > hoping this wouldn't be the answer, thanks :) > > another for you: > > I've now coded my function, and the ordering works fine. > > except I'm inside a class and would really rather not include some strange > little file with a single function in it. <kludge>my code here</kludge> > > on a whim, I tried > uasort($this->modules[$group], '$this->_ary_sort()'); > > with no luck :) > > ideas? sure :) use uasort( $this->modules[ $group], array( &$this, '_ary_sort'))' You could also write '$this' instead of '&$this' and it would work but would unneccessarily create a new copy of the object. - Markus

« previous php.general (#53863) next »