Re: sort multidim array
| From: | Jasper Howard | Date: | Tue, 05 Oct 2004 17:51:56 +0000 |
| Subject: | Re: sort multidim array | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-198697@lists.php.net to get a copy of this message | ||
This was just discusses in quite some detail. Everyone decieded that
usort() was the best and a couple peopel agreed that array_multisory()
works just fine. Check out that convo to get some pretty good details
on how to do this.
On Tue, 05 Oct 2004 13:04:44 -0400, Kevin Coyner <kevin@rustybear.com> wrote:
>
> I've been banging my head against the wall on this one. Probably
> trivial to the knowledgeable, but I'm stumped despite trying the various
> sort functions as advertised on php.net.
>
> I've got the following fields:
>
> retailer city state telephone distance
>
> Sample data looks like:
>
> BLIND BROOK CLUB PURCHASE, NY (914) 939-1450 4.6
> BURNING TREE CC GREENWICH, CT (203) 869-9010 0
> CENTURY COUNTRY CLUB PURCHASE, NY (914) 761-0400 4.6
> FAIRVIEW CC GREENWICH, CT (203) 531-4283 2.2
> ......
>
> All of this is in an array I'll call $zipArray.
>
> When I get the data from mysql, it doesn't contain the 'distance' info.
> The distance field is calculated and tacked onto each row by having
> everything go through a foreach loop.
>
> So I start with an array that has 4 data columns (retailer, city, state
> and telephone) and I end up with an array that has 5 data columns
> (retailer, city, state, telephone, and distance).
>
> If I apply asort($zipArray) it sorts nicely on the first data column -
> retailer. But I need it to sort on the last data column - distance.
>
> I think I've been staring at this too long. Would appreciate any
> guidance.
>
> Thanks
> Kevin
>
> --
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
<<--------------------------------------------------------
Jasper Howard - Database Administration
ApexEleven.com
530 559 0107
------------------------------------------------------->>