[ $_, s/^CAORE//r =~ s/(\d+)/sprintf "%06d", $1/ger ] } @aa;
I don't understand the s/^CAORE//r part of this expression. It seems to be doing nothing, and the sorted output is the same without it:
Can you please elaborate?c:\@Work\Perl\monks>perl -wMstrict -le "my @aa = qw( CORE1 CORE12 CORE8 CORE233 COREA11 COREA12 COREA130 COREA115 ); my @sorted = map { $_->[0] } sort { $a->[1] cmp $b->[1] } map { [ $_, s/(\d+)/sprintf \"%06d\", $1/ger ] } @aa; print qq{@sorted}; " CORE1 CORE8 CORE12 CORE233 COREA11 COREA12 COREA115 COREA130
Give a man a fish: <%-{-{-{-<
In reply to Re^2: sorting number
by AnomalousMonk
in thread sorting number
by dideod.yang
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |