X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=C4%2FClassSortRoutine%2FDewey.pm;h=25480ec082da9fc8dd05147994f96a45ebdb8c64;hb=4bbda034644723750a11c5693953390cc229a0a7;hp=62a68b91cef68fa01d2b90afbdd977fa6eb4286c;hpb=ce037a96eb173e300a564ca96415d8c8bbe304b9;p=koha_fer diff --git a/C4/ClassSortRoutine/Dewey.pm b/C4/ClassSortRoutine/Dewey.pm index 62a68b91ce..25480ec082 100644 --- a/C4/ClassSortRoutine/Dewey.pm +++ b/C4/ClassSortRoutine/Dewey.pm @@ -23,7 +23,7 @@ use warnings; use vars qw($VERSION); # set the version for version checking -$VERSION = 3.00; +$VERSION = 3.07.00.049; =head1 NAME @@ -67,9 +67,13 @@ sub get_class_sort_key { $init =~ s/^([\p{IsAlpha}]+)/$1 /; my @tokens = split /\.|\s+/, $init; my $digit_group_count = 0; + my $first_digit_group_idx; for (my $i = 0; $i <= $#tokens; $i++) { if ($tokens[$i] =~ /^\d+$/) { $digit_group_count++; + if (1 == $digit_group_count) { + $first_digit_group_idx = $i; + } if (2 == $digit_group_count) { $tokens[$i] = sprintf("%-15.15s", $tokens[$i]); $tokens[$i] =~ tr/ /0/; @@ -78,7 +82,7 @@ sub get_class_sort_key { } # Pad the first digit_group if there was only one if (1 == $digit_group_count) { - $tokens[0] .= '_000000000000000' + $tokens[$first_digit_group_idx] .= '_000000000000000' } my $key = join("_", @tokens); $key =~ s/[^\p{IsAlnum}_]//g;