in reply to sorting number

A fairly standard approach is to break the identifier up into a letter part and a number part, sort by each as needed, then join the bits back together again. There is a Perl idiom that makes that fairly easy and clean to do:

use strict; use warnings; my @rawList = qw( CORE1 COREA11 CORE12 COREA130 CORE8 CORE233 COREA12 COREA115 ); my @sortedList = # Join letter and number parts back together map{$_->[0] . $_->[1]} # sort first by letter part, then if that is equal sort by number +part sort {$a->[0] cmp $b->[0] || $a->[1] <=> $b->[1]} # Use a regex to split each item into a letter part and a number p +art map{[/([^\d]+)([\d]+)/]} @rawList; print join "\n", @sortedList;

Prints:

CORE1 CORE8 CORE12 CORE233 COREA11 COREA12 COREA115 COREA130

Note that map takes a list, processes each element, and returns a new list. The expression executes its main parts essentially from right to left: the last map executes first, then the sort, then finally the first map.

Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond