Hi all,
I have another question. I have an array sorted like this:
small_motif_a 1853 1863
small_motif_a 1970 1980
small_motif_a 1971 1981
small_motif_b 789 799
small_motif_b 882 892
small_motif_b 1181 1191
small_motif_b 1193 1203
small_motif_b 1264 1274
and so on
now I want to sort it ascending. I tried it with this code:
but it is not working.
Anyone an idea please?
I have another question. I have an array sorted like this:
small_motif_a 1853 1863
small_motif_a 1970 1980
small_motif_a 1971 1981
small_motif_b 789 799
small_motif_b 882 892
small_motif_b 1181 1191
small_motif_b 1193 1203
small_motif_b 1264 1274
and so on
now I want to sort it ascending. I tried it with this code:
Code:
#!/usr/bin/perl -w use strict; use Bio::Perl; my @var; my @lines; my @sort_col; @sort_col=(); @lines=(); @var=(); my $column; my $varfilename; print "Enter the filename of your input file with the variants:= "; chomp ($varfilename=<STDIN>); open (VARINPUT,'<',$varfilename) or die ("$varfilename Can not open file\n"); @var=<VARINPUT>; #print @var; $column=1; while(<VARINPUT>) { s/\r?\n//; @var=split /\t/, $_; push @sort_col, $var[$column]; push @lines, "$_\n"; } @lines=sort {$sort_col[$b] <=> $sort_col[$c] } @lines; warn "\nSorted $. lines in ascending order, based on numerical values in column $column\n\n"; print @lines [sort { $sort_col[$b] <=> $sort_col[$c] } 0..$#sort_col]; print "@lines\n";
Anyone an idea please?
Comment