array arrangement by one column with perl or shell(矩阵根据某列排序(shell和perl))

#!/usr/bin/perl -w
use strict;
use warnings;
use Data::Dumper;

my $colnum;
my $n=0;
my $rownum=0;
my @list;

open(RF,"segmentationfile.txt") || die $!;
while(my $line=<RF>){
    chomp $line;
    my @arr=split("\t",$line);
    for my $i (0..$colnum-1){

my @data=sort{ $a ->[1] cmp $b -> [1] } @list;

open(WF,">paixu_seg.txt") || die $!;
for my $i (0..$rownum-1){
    for my $j (0..$colnum-1){
        if ($j<$colnum-1){
            print WF $data[$i][$j]."\t";
            print WF $data[$i][$j]."\n";


sort -k 2 -n  segmentationfile.txt | perl -e 'while(<>){chomp;@arr=split("\t",$_);if($arr[1]=~m/^[^\D]/){print $_."\n"}}' > 1.txt
sort -k 2 -n  segmentationfile.txt | perl -e 'while(<>){chomp;@arr=split("\t",$_);if($arr[1]=~m/^\D/){print $_."\n"}}' >> 1.txt
mv 1.txt segmentationfile_sort.txt
此条目发表在Linux, Perl分类目录。将固定链接加入收藏夹。


电子邮件地址不会被公开。 必填项已用*标注

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    Markdown is turned off in code blocks:
     [This is not a link](

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see

Protected with IP Blacklist CloudIP Blacklist Cloud