use Sort::Key qw(nkeysort); # the 'n' is for numeric my @sorted = nkeysort { substr $_, 6 } @array;