[MacPerl-AnyPerl] Sorting a list of alphanumeric strings

2001-08-24 Thread Adam Witney
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

[MacPerl-AnyPerl] Re: Sorting a list of alphanumeric strings

2001-08-24 Thread David Iberri
> 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

Re: [MacPerl-AnyPerl] Sorting a list of alphanumeric strings

2001-08-24 Thread David Iberri
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; $

Re: [MacPerl-AnyPerl] Sorting a list of alphanumeric strings

2001-08-24 Thread Jay Bedsole
There's a module on CPAN that does what you want, I think. Sort::Naturally

[MacPerl-AnyPerl] Re: Sorting a list of alphanumeric strings

2001-08-24 Thread Randal L. Schwartz
> "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