Re: Sorting an Array of Arrays

2007-03-14 Thread Randal L. Schwartz
Mumia == Mumia W mumia.w.18.spam writes: Mumia On 03/13/2007 07:44 PM, Hardly Armchair wrote: Hello List, I have a data structure containing a bunch of strings in different groups: [...] I want these sorted first alphabetically within the group, and then according to the number of member

Sorting an Array of Arrays

2007-03-13 Thread Hardly Armchair
Hello List, I have a data structure containing a bunch of strings in different groups: $groups = [ [ 'SSPDQR', 'SSPSDR', 'STSSER', ], [ 'CSANLH', 'CVANRD', ], [...],

Re: Sorting an Array of Arrays

2007-03-13 Thread John W. Krahn
Hardly Armchair wrote: Hello List, Hello, I have a data structure containing a bunch of strings in different groups: $groups = [ [ 'SSPDQR', 'SSPSDR', 'STSSER', ], [ 'CSANLH',

Re: Sorting an Array of Arrays

2007-03-13 Thread Mumia W.
On 03/13/2007 07:44 PM, Hardly Armchair wrote: Hello List, I have a data structure containing a bunch of strings in different groups: [...] I want these sorted first alphabetically within the group, and then according to the number of member in the group. [...] This is slightly more

RE: sorting an array of arrays by arr_el[$idx][2] (or something like that)

2006-04-18 Thread Thomas Bätzler
Ed [EMAIL PROTECTED] asked: [...] I'm reading from a file and constructing an array of arrays. Here's an example of what's in the file: net localgroup Field Aidan /ADD [...] I want to sort the lines in the file by the 3rd column (Field, Internal, CM, DocAdmin) If you're not particularly

RE: sorting an array of arrays by arr_el[$idx][2] (or something like that)

2006-04-18 Thread Charles K. Clarkson
Ed wrote: : my @lineArray; : while(F) : { : # if the line is a net localgroup line add it to the array : if( $_ =~ $s_criteria ) You probably should be testing against a regular expression. if ( $_ =~ /$s_criteria/ ) Or just: if ( /$s_criteria/ ) :

Re: sorting an array of arrays by arr_el[$idx][2] (or something like that)

2006-04-18 Thread M. Kristall
Ed wrote: I want to sort the lines in the file by the 3rd column (Field, Internal, CM, DocAdmin) Since Perl doesn't really support multidimensional arrays but instead uses references, something like this should work: sort { $$a[2] cmp $$b[2] } @array; This is more or less like the typical

Re: sorting an array of arrays by arr_el[$idx][2] (or something like that)

2006-04-18 Thread John W. Krahn
Thomas Bätzler wrote: Ed [EMAIL PROTECTED] asked: push( @lineArray, @_ ); ---no it's an array of arrays. This will append all the items in @_ to @lineArray. You shoul've said push( @lineArray, [EMAIL PROTECTED] ); instead. No he shouldn't have. @_ is a global variable so

Re: sorting an array of arrays by arr_el[$idx][2] (or something like that)

2006-04-18 Thread John W. Krahn
Charles K. Clarkson wrote: Ed wrote: : push( @lineArray, @_ ); ---no it's an array of arrays. An array of arrays is a short name for an array of array references. Array elements can only hold scalar values and arrays are not scalars. References to arrays are scalars.

sorting an array of arrays by arr_el[$idx][2] (or something like that)

2006-04-17 Thread Ed
I'm still hobbled by my thinking in C problem so I'm looking for a way to do this. I'm reading from a file and constructing an array of arrays. Here's an example of what's in the file: net localgroup Field Aidan /ADD net localgroup Internal Aidan /ADD net localgroup CM Aidan /ADD net localgroup