Re: Sort an array by its values
| From: | Justin Farnsworth | Date: | Sun, 08 Jul 2001 09:08:51 +0000 |
| Subject: | Re: Sort an array by its values | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-56741@lists.php.net to get a copy of this message | ||
Try something like:
uasort($your_hash[$first_level][$any_second_level],
create_function('$a,$b', 'return $a["what_level"] -
$b["what_level"];'));
and adjust this according to the level and what you want to sort on
accordingly...
_jef
--------------------
Aaron Bennett wrote:
>
> Hi All,
> I'm trying to sort an array of objects by the value of one of those
> objects...
> for instance, I'll have an object with 2 properties, "id" and "score",
> where
> id is unique and score is its relevant (and sometimes simelar) score. i've
> tried using sort() and asort() but i can't figure how to base the sorting
> off the value (i.e. score) of the object in the array. Any help?
> --
> Aaron
--
Justin Farnsworth
Eye Integrated Communications
321 South Evans - Suite 203
Greenville, NC 27858 | Tel: (252) 353-0722