Re: Sorting an array by one of it's fields.

2001-06-18 Thread Tirthankar C.P
Thanks a million to Jos Boumans, and Me (whoever that is). Me, thanks for the explanation, and Jos, for your patient and detailed answer. -tir On Sat, 16 Jun 2001, Me wrote: > > This should've worked. But why do I get a warning: > > > > Use of uninitialized value at ./mk2_ratingchangedb.p

Re: Sorting an array by one of it's fields.

2001-06-16 Thread Me
> This should've worked. But why do I get a warning: > > Use of uninitialized value at ./mk2_ratingchangedb.pl line 39, chunk 8. Whenever you're dealing with baffling array errors like this, always think of off-by-one. In this case: > 30 for ($i=1; ...) { > 31 $dummy[$i][

Re: Sorting an array by one of it's fields.

2001-06-16 Thread Jos I. Boumans
same applies here again. this is the trick used: we dig out that value we want to sort on, make that the key of our hash and go from there let me adres the @arr you presented. ### EXAMPLE 1 ### ### this will NOT eliminate the value we're sorting on from the list ### while ( my @s = splice(@a

Re: Sorting an array by one of it's fields.

2001-06-16 Thread Tirthankar C.P
Thnaks a lot Jos. The idea of reading the array into a hash is quite appealing, and simple too. But I have a small problem with this: What if I want to sort on the second column of the array? Or if there are more than two columns? Say we have: my @arr = qw( 1 2 3 4 4 5 6 7 5 6 7 8 1 2 3 4 3

Re: Sorting an array by one of it's fields.

2001-06-16 Thread Jos I. Boumans
ok, so if i get this right, @dummy has the following format: my @dummy = qw( 1996013100:00:00MAAA 281100:00:00MA- 1997063000:00:00MAAA 1998122200:00:00MAA 2000112400:00:00MD ); now we have that established, let'

Sorting an array by one of it's fields.

2001-06-16 Thread Tirthankar C.P
Folks, # How do I sort an array by one of it's fields? I have a this code: for ($i=1; $i<=$N; $i++) { } $dummy[$i][0] = &ParseDate($data{$key}[$i][0]); if (! $dummy[$i][0]) { } warn "Could not parse $data{$key}[$i][0]\n"; } $dummy[$i][1] = $da