in reply to Need Help! Two Dimentional Array Sorting
Also, you might try dropping use strict; use warnings; at the top of everything you do. I *think* that would have helped you spot the main problem a little bit sooner.
That all being said, I tried the following, and I got the results you were expecting.
Of course you say you're trying to sort a two dimensional array in the subject, but this array isn't two dimensional, so I suspect you're not telling the whole story.use strict; use warnings; my @Records; open(FILE,"file.txt"); while (<FILE>){ @Records = <FILE>; } @Records = sort {$a cmp $b} @Records; # and now to test. my $i = 0; while ($i <= $#Records){ print "$Records[$i]\n"; $i++; }
Cheers!
|
|---|