RE: [PHP] Need some help with array sorting
| From: | Will Steffen | Date: | Fri, 13 Sep 2002 08:07:52 +0000 |
| Subject: | RE: [PHP] Need some help with array sorting | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-116239@lists.php.net to get a copy of this message | ||
Thanks Timo
I figured if it was do-able it would be something like uasort, or uksort
or one of those, but my geek muscles arent quite up to that sort of flex
yet - any one mind giving me some clues as to how to get started using
these functions - the manual gets pretty vague in this area?
Thanks
Will
> -----Original Message-----
> From: t.stamm@web.de [mailto:t.stamm@web.de]
> Sent: 13 September 2002 08:41 AM
> To: php-general@lists.php.net
> Cc: timo stamm; Will Steffen
> Subject: Re: [PHP] Need some help with array sorting
>
>
> Hi Will,
>
>
> You need a customized sort. Have a look at uasort().
>
>
> Timo
>
>
> Am Donnerstag den, 12. September 2002, um 13:32, schrieb Will Steffen:
>
> > Ahem *tap* *tap* is this thing on?
> >
> > Hi everyone, my name is Will and I've been addicted to php for 3
> > months and 21 days... *grin*
> >
> > I'm hitting a bit of a brick wall in a current project -
> the answer is
> > probably quite simple, but I'm still newish to php and coding in
> > general so bear with me:
> >
> > I have a multidim array which looks something like :
> >
> > $blocks[0] = array("param1"=>"4","param2"=>"some
> > other param")
> > $blocks[1] = array("param1"=>"3","param2"=>"some
> > other param")
> > $blocks[2] = array("param1"=>"6","param2"=>"some
> > other param")
> >
> > And so forth
> >
> > Fairly straight forward you say, my problem is that elements can be
> > inserted into the blocks array in no particular order and I need to
> > sort at the top level using the values in param1 - so my
> output should
> > be:
> >
> > $sorted_blocks[0] =
> > array("param1"=>"3","param2"=>"some
> other param")
> > $sorted_blocks[1] =
> > array("param1"=>"4","param2"=>"some
> other param")
> > $sorted_blocks[2] =
> > array("param1"=>"6","param2"=>"some
> other param")
> >
> > I've had a long hard look at the manual and all those obscure array
> > manipulation goodies (ksort, multisort, etc) and done some
> hunting on
> > phpbuilder and the like, but turned up zip - either I'm not
> > understanding the array functions properly, or this can't
> be done, or
> > there's a nifty trick for doing it which I havent figured out?
> >
> > Ideally I'd like to be populating blocks using an sql query
> so I could
> > do an order by or some such upfront, but this world is anything but
> > ideal.
> >
> > Any1 got 2c for me?
> >
> >
> > Thanks in advance
> > Will
> >
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
>