use strict; use warnings; use Test::More tests => 1; my @arrayUnsorted = ('page1.html', 'page11.html', 'page2.html', 'page3.html'); my @arraySorted = ('page1.html', 'page2.html', 'page3.html', 'page11.html'); my @have = sort { substr ($a, 4, 2) <=> substr ($b, 4, 2) } @arrayUnsorted; is_deeply \@have, \@arraySorted;