Pad all numeric parts before sorting:
my @sects= qw( 1 2 2.2 2.13 2.1.7 3.4a 10.1 10.10 10.1a 1a.2 ); my $maxdigs= 4; my %sects; foreach my $sect ( @sects ) { ( my $sort= $sect ) =~ s/(\d+)/ sprintf "%0$maxdigs.$maxdigs"."d", $1 /ge; $sects{$sort}= $sect; } print join( " ", @sects{ sort keys %sects } ), "\n";
In reply to Re: Sorting on Section Numbers
by tye
in thread Sorting on Section Numbers
by Zoogie
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |