Hi,
I am trying to sort a list like this
exon1
exon5
exon12
exon30
exon2
Into ->
exon1
exon2
exon5
exon12
exon30
Any ideas on how to do this?
Thanks
adam
> ok, seriously, we'll also assume no two entries have
> the same number, and if
> they did you'd want to delete repeats. This makes
> things a lot easier.
>
> #! perl
>
> open FILE, 'file.txt';
> @list = ; # get list into array or by some
> other means
> # keep the line brea
This was my first guess, but I'm sure there are better
ways:
my @ary = qw(exon1
exon5
exon12
exon30
exon2);
@ary = sort by_exon_num @ary;
print join("\n", @ary), "\n";
sub by_exon_num {
$a =~ /(\d+)/;
my $a_dig = $1;
$
There's a module on CPAN that does what you want, I think.
Sort::Naturally
> "Adam" == Adam Witney <[EMAIL PROTECTED]> writes:
Adam> Hi,
Adam> I am trying to sort a list like this
Adam> exon1
Adam> exon5
Adam> exon12
Adam> exon30
Adam> exon2
Adam> Into ->
Adam> exon1
Adam> exon2
Adam> exon5
Adam> exon12
Adam> exon30
Adam> Any ideas on how to do this?
my @sorted