Well, you could try something like this.  I stored the file as an array of
arrays:

use strict;

open(INFILE,"test.tab");

my @temp;
my @sort;
my @infile;
my $count = 0;

while(<INFILE>){
        chomp $_;
        print "$_\n";
        my $temp;
        @{$temp} = split /\t/,$_;
        push @infile,$temp;
}

foreach(@infile){
        push @sort,"${$_}[2],$count";
        $count++;
}

@sort= sort @sort;

foreach(@sort){
        my($field,$index) = split /,/,$_;
        my $temp = join "\t",@{$infile[$index]};
        print $temp."\n";
        push @temp,$temp;
}
undef @temp;
@sort = @temp;

foreach(@sort){
        print $_."\n";
}   

-----Original Message-----
From: Bryan R Harris [mailto:[EMAIL PROTECTED]]
Sent: Thursday, April 04, 2002 7:49 AM
To: [EMAIL PROTECTED]
Subject: sort by field




I'm very much a beginner, I guess, the perldoc page on sort doesn't make
much sense to me.

I've got a tab-delimited file read into an array, now I want to sort it on
the contents of column 3.  Could someone point me in the right direction?

TIA.

- Bryan



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


--------------------------------------------------------------------------------
This email may contain confidential and privileged 
material for the sole use of the intended recipient. 
If you are not the intended recipient, please contact 
the sender and delete all copies.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to