Re: Sorting a list of alphanumeric strings

[email protected] ((Randal L. Schwartz)) 24 Aug 2001 19:06:07 -0700
Newsgroups perl.macperl.anyperl
Organization Stonehenge Consulting Services; Portland, Oregon, USA
Message-ID <[email protected]>
>>>>> "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 = sort { substr($a, 4) <=> substr($b, 4) } @input;

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[email protected]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!