Re: sort(ing)
| From: | Ed Vul | Date: | Thu, 06 Jul 2000 23:30:11 +0000 |
| Subject: | Re: sort(ing) | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-5287@lists.php.net to get a copy of this message | ||
Hey, thanks a lot, I was hoping there was a premade function so i wouldnt
have to make my own, but you making it for me is just as good :)
thanks a lot!
ed
""Chris Adams"" <chris@digitaria.com> wrote in message
news:089301bfe7a1$5bf643c0$0a65a8c0@digitaria.com...
> > 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;
> }
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>