## Build an array of anonymous arrays, ## each of which contains the sort field and the original element. @anons = map{ [ substr( $_, 1 ) , $_ ] } qw[ A473 B659 C123 D222 E001 ];; print Dumper \@anons;; $VAR1 = [ ['473','A473'],['659','B659'],['123','C123'], ['222','D222'],['001','E001'] ]; ## Now sort the anonymous arrays ## by comparing the extracted fields. @sortedAnons = sort{ $a->[ 0 ] <=> $b->[ 0 ] } @anons;; print Dumper \@sortedAnons;; $VAR1 = [ ['001','E001'],[123,'C123'],[222,'D222'], [473,'A473'],[659,'B659'] ]; ## Finally, build the required sorted array ## by extracting the original elements discarding the sort fields. @sorted = map{ $_->[ 1 ] } @sortedAnons;; print Dumper \@sorted;; $VAR1 = ['E001','C123','D222','A473','B659'];