#!/usr/bin/perl -w use strict; my @list = qw( C1 C12 R5 C3 C21 C2 C12 ); my @sort = map { $_->[0] } sort { $a->[1] cmp $b->[1] || $a->[2] <=> $b->[2] } map { [ $_, m/^(\D+)(\d+)/ ] } @list; print "@sort\n";