Richard Harb wrote:
Hi there,

Supposed I have an array of objects, like:

$this[$i]->property1
$this[$i]->property2

is there any 'cheap' way to sort the array according to the values of
property1?


http://www.php.net/usort


Example:

function cmp($a, $b)
{
   if ($a->property1 == $b->property1) {
       return 0;
   }
   return ($a->property1 < $b->property1) ? -1 : 1;
}

usort($object_array, "cmp");

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to