Re: tips on sorting an array of objects by an attribute?
| From: | Marek Kilimajer | Date: | Fri, 28 Mar 2003 14:48:04 +0000 |
| Subject: | Re: tips on sorting an array of objects by an attribute? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-141447@lists.php.net to get a copy of this message | ||
use usort
neko wrote:
Hi Guys, Just after some experience... What's the best way to sort an array of objects by one of their attributes, accessed by $obj->getFoo() (its a number) ? I was thinking a bubble-sort, making multiple passses and switching array elements until there are no more switches to make. Any tips? The array size is not very large (not will it ever be), so it's doesn't have to be a super-lean sorting algorithm (no harm though ;) ) cheers, neko