use strict; my @g = qw(St1 St10 St2 St12 St6 St8); my @b = sort{$a cmp $b} @g; foreach my $x (@b){ print "$x\n"; }