use strict; use warnings; my @aChapters=("ch1","ch11","ch2","ch5","ch55","ch16"); my @aSorted = sort { my ($sA, $iA) = ($a =~ /(^[^\d]+)(\d+)/); my ($sB, $iB) = ($b =~ /(^[^\d]+)(\d+)/); my $x = $sA cmp $sB; ($x = $iA <=> $iB) unless $x; $x; } @aChapters; local $"="\n"; print "@aSorted";