Re: Sorting Arrays
| From: | Robert Cummings | Date: | Fri, 22 Aug 2008 20:07:04 +0000 |
| Subject: | Re: Sorting Arrays | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-278545@lists.php.net to get a copy of this message | ||
On Fri, 2008-08-22 at 21:04 +0100, Ashley Sheridan wrote:
> Yeah, a bubble sorting algorithm should fix it, as it essentially only
> a very simple sort required.
Why use bubble sort when you can use usort() function with an arbitrary
handler?
Cheers,
Rob.
>
> Ash
> www.ashleysheridan.co.uk
> email message attachment, "Forwarded message - Re: [PHP] Sorting
> Arrays"
> > -------- Forwarded Message --------
> > From: Micah Gersten <micah@onshore.com>
> > To: Tom Shaw <php.coder@tx.rr.com>
> > Cc: php-general@lists.php.net
> > Subject: Re: [PHP] Sorting Arrays
> > Date: Fri, 22 Aug 2008 14:18:53 -0500
> >
> > I believe you'll need a custom sorting function for this.
> > http://us.php.net/usort
> >
> > Thank you,
> > Micah Gersten
> > onShore Networks
> > Internal Developer
> > http://www.onshore.com
> >
> >
> >
> > Tom Shaw wrote:
> > > I'm having a problem sorting my array and wondered if anybody had experience
> > > sorting arrays by their values. What I need to do is resort the array below
> > >
> > > where the most expensive product shipping price starts at position zero no
> > > matter how big the array is.
> > >
> > >
> > >
> > > array(2) {
> > >
> > > [0] => array(48) {
> > >
> > > ["product_id"] => string(2) "34"
> > >
> > > ["product_name"] => string(29) "Bears Ball Cap"
> > >
> > > ["product_ordered_size"] => string(5) "ADULT"
> > >
> > > ["product_sales_price"] => string(8) "11.90"
> > >
> > > ["product_shipping_price"] => string(4) "7.85"
> > >
> > > ["product_shipping_extra"] => string(4) "0.06"
> > >
> > > }
> > >
> > > [1] => array(48) {
> > >
> > > ["product_id"] => string(2) "37"
> > >
> > > ["product_name"] => string(21) "Baldwin L Grand Piano"
> > >
> > > ["product_ordered_size"] => string(5) "Grand"
> > >
> > > ["product_sales_price"] => string(8) "11671.90"
> > >
> > > ["product_shipping_price"] => string(6) "500.00"
> > >
> > > ["product_shipping_extra"] => string(6) "450.00"
> > >
> > > }
> > >
> > >
> > >
> > > Thanks
> > >
> > >
> > >
> > > php.coder@tx.rr.com
> > >
> > >
> > >
> >
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
--
http://www.interjinn.com
Application and Templating Framework for PHP