G'day dideod.yang,
What you have as "I want to print ..." is not really sorted. Perhaps you wrote COREA12 and COREA115 around the wrong way. If that's the case, you'd need to split each element into alphabetic and numeric parts but do a string comparison on both of them:
$ perl -E ' say map "$_->[0]$_->[1] ", sort { $a->[0] cmp $b->[0] || $a->[1] cmp $b->[1] } map [/(\D+)(\d+)/], qw{ CORE1 CORE12 CORE8 CORE233 COREA11 COREA12 COREA130 COREA115 } ' CORE1 CORE12 CORE233 CORE8 COREA11 COREA115 COREA12 COREA130
— Ken
In reply to Re: sorting number
by kcott
in thread sorting number
by dideod.yang
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |