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

Re: [PHP] array sort help...

2003-06-11 Thread Lars Torben Wilson
On Wed, 2003-06-11 at 12:10, Dan Joseph wrote: > Hi, > > I cannot figure this out... Need some assistance. > > I have an array: > > $jack[#] = array( > "loan_info" => 101, > "first_name" => jack, > "last_name" => mother > ); > >

[PHP] array sort help...

2003-06-11 Thread Dan Joseph
Hi, I cannot figure this out... Need some assistance. I have an array: $jack[#] = array( "loan_info" => 101, "first_name" => jack, "last_name" => mother ); # = 0 thru 12 I want to sort the array by

Re: [PHP] array sort

2001-05-22 Thread Alex Black
> on a whim, I tried > uasort($this->modules[$group], '$this->_ary_sort()'); hi all, for those of you interested: uasort($this->modules[$group], array(&$this,'_ary_sort')); note the &$this... this is a very good point, if you use $this, a new instance of your class is created just to han

Re: [PHP] array sort

2001-05-22 Thread Markus Fischer
On Mon, May 21, 2001 at 06:05:49PM -0700, Alex Black wrote : > > Use 'uasort()': > > > > function my_hash_sort( $a, $b) { > > $a = $a['num']; > > $b = $b['num']; > > if( $a == $b) return 0; > > return ( $a > $b) ? -1 : 1; > > } > > > > uasort( $test, 'my_hash_sort'); > > hoping this wouldn't b

Re: [PHP] array sort

2001-05-21 Thread Alex Black
> Use 'uasort()': > > function my_hash_sort( $a, $b) { > $a = $a['num']; > $b = $b['num']; > if( $a == $b) return 0; > return ( $a > $b) ? -1 : 1; > } > > uasort( $test, 'my_hash_sort'); hoping this wouldn't be the answer, thanks :) another for you: I've now coded my function, and the orderin

Re: [PHP] array sort

2001-05-21 Thread Markus Fischer
On Mon, May 21, 2001 at 03:19:28PM -0700, Alex Black wrote : > hi all, > > I'm trying to do an array sort that takes: > > $test = array( > array( // this is $test[0]. > string => "this is the second", > num => 2 > ), > array( // this is $test[

[PHP] array sort

2001-05-21 Thread Alex Black
hi all, I'm trying to do an array sort that takes: $test = array( array( // this is $test[0]. string => "this is the second", num => 2 ), array( // this is $test[1]. string=> "this is the first", num => 1 ),

Re: [PHP] Array Sort?

2001-04-09 Thread Chris Anderson
heh, sounds fun. Oh well Thanks - Original Message - From: "David Robley" <[EMAIL PROTECTED]> To: "Chris Anderson" <[EMAIL PROTECTED]>; "Chris Anderson" <[EMAIL PROTECTED]>; "PHP" <[EMAIL PROTECTED]> Sent: Monday, April 09

Re: [PHP] Array Sort?

2001-04-09 Thread David Robley
On Fri, 6 Apr 2001 18:33, Chris Anderson wrote: > Currently I am using the sort() command to sort an array. Unfortunately > it uses the ascii number so all words starting with uppercase are > before lowercase. Is there a case insensitive alphabetical sort that I > don't know of? Thanks in advance

[PHP] Array Sort?

2001-04-09 Thread Chris Anderson
Currently I am using the sort() command to sort an array. Unfortunately it uses the ascii number so all words starting with uppercase are before lowercase. Is there a case insensitive alphabetical sort that I don't know of? Thanks in advance ^_^