RE: [PHP] Array sort question

2006-02-28 Thread tedd
I would rather teach a man how to fish than give him his supper on a silver platter. Write his code and you can reduce his frustration for a day, but teach him to program and you'll frustrate him for life. tedd -- ---

RE: [PHP] Array sort question

2006-02-28 Thread jblanchard
[snip] That's not entirely fair. I would have said his usort() suggestion was a better pointer than a link to count() - which gives no hint as to how to sort the list, which is after all what the OP's trying to do. ObSuggestion: function byLength($a, $b) { return sizeof($a) - sizeof($b); } us

Re: [PHP] Array sort question

2006-02-28 Thread Robin Vickery
On 28/02/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > The array sorting suggestions you provide will not sort based on the > number of items in each array, which is what the OP wanted. That's not entirely fair. I would have said his usort() suggestion was a better pointer than a link to coun

RE: [PHP] Array sort question

2006-02-28 Thread jblanchard
[snip] If you say so. In that case, jblanchard, I apologize for my outburst. [/snip] Apology accepted. Look, several of us have been on this list for years and have helped several others through their issues. Mailing lists like this (try a C++ newsgroup for example) are much more merciless than so

Re: [PHP] Array sort question

2006-02-28 Thread John Nichel
Jeremy Privett wrote: [EMAIL PROTECTED] wrote: [snip] How can I sort a 2 dimensional array by number of elements? [/snip] Start by RTFM http://www.php.net/manual/en/function.count.php I love how infinitely helpful people on this mailing list are. It's a wonder people are being turn

Re: [PHP] Array sort question

2006-02-28 Thread Jeremy Privett
Saline Erik wrote: Sometimes I just need a point in the right direction. So RTFM is not so bad. Erik If you say so. In that case, jblanchard, I apologize for my outburst. -- Jeremy Privett Director of Product Development Zend Certified Engineer Completely Unique [EMAIL PROTECTED] Phone:

Re: [PHP] Array sort question

2006-02-28 Thread Jeremy Privett
[EMAIL PROTECTED] wrote: [snip] I love how infinitely helpful people on this mailing list are. It's a wonder people are being turned off to PHP. There's no one here willing to help new people more than throwing them "RTFM" responses. [/snip] Are you new here? I would rather teach a man how to fi

Re: [PHP] Array sort question

2006-02-28 Thread Saline Erik
Sometimes I just need a point in the right direction. So RTFM is not so bad. Erik On Feb 28, 2006, at 11:26 AM, <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> wrote: [snip] I love how infinitely helpful people on this mailing list are. It's a wonder people are being turned off to PHP. There's

RE: [PHP] Array sort question

2006-02-28 Thread jblanchard
[snip] I love how infinitely helpful people on this mailing list are. It's a wonder people are being turned off to PHP. There's no one here willing to help new people more than throwing them "RTFM" responses. [/snip] Are you new here? I would rather teach a man how to fish than give him his supper

Re: [PHP] Array sort question

2006-02-28 Thread Jeremy Privett
[EMAIL PROTECTED] wrote: [snip] How can I sort a 2 dimensional array by number of elements? [/snip] Start by RTFM http://www.php.net/manual/en/function.count.php I love how infinitely helpful people on this mailing list are. It's a wonder people are being turned off to PHP. There's

RE: [PHP] Array sort question

2006-02-28 Thread jblanchard
[snip] How can I sort a 2 dimensional array by number of elements? [/snip] Start by RTFM http://www.php.net/manual/en/function.count.php

[PHP] Array sort question

2006-02-28 Thread PHP
  Hi, How can I sort a 2 dimensional array by number of elements? Ex:   rgArray[0] = ("1","2"); rgArray[1] = ("1"); rgArray[2] = ("1","2","3","4"); rgArray[3] = ("1","2","3");   Now I would like to sort it so I can loop through them from least elements to most (or vice versa):   rgArray[1]   (

RE: [PHP] array sort question

2004-10-02 Thread Ed Lazor
Thanks for the example using array_multisort. I'd been wondering how I could use that function to do what I want. It looks like it's more flexible in the long run, but I was able to use Paul's recommendation to do what I want. Here's the code I ended up using: function cmp ($a, $b) { return

Re: [PHP] array sort question

2004-10-02 Thread Jasper Howard
Sorry for the empty reply (miss slide of the finger on my touch pad). You can use array_multisort(); The code would look something like this, remember, this is untested code so be warned before any flaming is done: //CODE //You need to restructure your array like this: $menu["ID"][1] = 5; $menu["T

Re: [PHP] array sort question

2004-10-02 Thread Jasper Howard
On Fri, 1 Oct 2004 22:44:50 -0400, Paul Bissex <[EMAIL PROTECTED]> wrote: > On Fri, 1 Oct 2004 19:12:30 -0700, Ed Lazor <[EMAIL PROTECTED]> wrote: > > Any ideas on how I could sort this array by Title? > > > > $menu[1]["ID"] = 5; > > > > $menu[1]["Title"] = "Test 1"; > > > > $menu[2]["ID"] = 3; > >

Re: [PHP] array sort question

2004-10-01 Thread Paul Bissex
On Fri, 1 Oct 2004 19:12:30 -0700, Ed Lazor <[EMAIL PROTECTED]> wrote: > Any ideas on how I could sort this array by Title? > > $menu[1]["ID"] = 5; > > $menu[1]["Title"] = "Test 1"; > > $menu[2]["ID"] = 3; > > $menu[2]["Title"] = "Test 4"; uasort() is what you need here. Also see the usort()

[PHP] array sort question

2004-10-01 Thread Ed Lazor
Any ideas on how I could sort this array by Title? $menu[1]["ID"] = 5; $menu[1]["Title"] = "Test 1"; $menu[2]["ID"] = 3; $menu[2]["Title"] = "Test 4"; $menu[3]["ID"] = 56; $menu[3]["Title"] = "Test 8"; $menu[4]["ID"] = 44; $menu[4]["Title"] = "Test 3"; Thanks, -Ed