Re: sort(ing)
| From: | Chris Adams | Date: | Thu, 06 Jul 2000 23:24:39 +0000 |
| Subject: | Re: sort(ing) | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-5286@lists.php.net to get a copy of this message | ||
> You must have misunderstood me... these are in an array, and sort() sorts
> them in the manner of:
> 1,123,34,45,457,5,9
> I think it is intended for alphabetical sorting...
> is there some numerical sorting function?
Use usort() with a function like this:
function cmp ($a, $b) {
$a = intval($a);
$b = intval($b);
if ($a == $b) return 0;
return ($a < $b) ? -1 : 1;
}