Hi, and welcome to perlmonks. Before moving on to the main questions, I'll get the mandatory "please use code tags" thing out of the way for displaying code. It helps everything look perty.
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.
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++;
}
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.
Cheers!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.