use strict;
use warnings;
use 5.010;
my $file = 'matrixin.txt';
my @data;
open( FILE, $file ) or die "Can't open file '$file': $!";
while(
chomp;
my @row = split;
push @data, \@row;
}
close( FILE );
my @sorted = sort { $a->[1] <=> $b->[1] } @data; ##sort by col 2
#Print output
for my $i (0..$#sorted)
{
for my $j (0..$#{$sorted[0]})
{
print "$sorted[$i][$j]","\t";
}
print "\n";
}
No comments:
Post a Comment