View | Details | Raw Unified | Return to bug 41685
Collapse All | Expand All

(-)a/C4/AuthoritiesMarc.pm (-10 / +14 lines)
Lines 1077-1083 sub BuildSummary { Link Here
1077
            }
1077
            }
1078
        }
1078
        }
1079
        my @fields = _marc21_sort_hierarchy_alpha( $record->field('4..') );
1079
        my @fields = _marc21_sort_hierarchy_alpha( $record->field('4..') );
1080
        foreach my $field (@fields) { #See From
1080
        foreach my $field (@fields) {    #See From
1081
            my $type = 'seefrom';
1081
            my $type = 'seefrom';
1082
            $type = ( $marc21controlrefs{ substr $field->subfield('w'), 0, 1 } || '' ) if ( $field->subfield('w') );
1082
            $type = ( $marc21controlrefs{ substr $field->subfield('w'), 0, 1 } || '' ) if ( $field->subfield('w') );
1083
            if ( $type eq 'notapplicable' ) {
1083
            if ( $type eq 'notapplicable' ) {
Lines 1101-1107 sub BuildSummary { Link Here
1101
            }
1101
            }
1102
        }
1102
        }
1103
        @fields = _marc21_sort_hierarchy_alpha( $record->field('5..') );
1103
        @fields = _marc21_sort_hierarchy_alpha( $record->field('5..') );
1104
        foreach my $field (@fields) { #See Also
1104
        foreach my $field (@fields) {    #See Also
1105
            my $type = 'seealso';
1105
            my $type = 'seealso';
1106
            $type = ( $marc21controlrefs{ substr $field->subfield('w'), 0, 1 } || '' ) if ( $field->subfield('w') );
1106
            $type = ( $marc21controlrefs{ substr $field->subfield('w'), 0, 1 } || '' ) if ( $field->subfield('w') );
1107
            if ( $type eq 'notapplicable' ) {
1107
            if ( $type eq 'notapplicable' ) {
Lines 1235-1248 sub BuildSummary { Link Here
1235
1235
1236
sub _marc21_sort_hierarchy_alpha {
1236
sub _marc21_sort_hierarchy_alpha {
1237
    my @fields = @_;
1237
    my @fields = @_;
1238
    return sort {
1238
    return (
1239
        # Sort broader (g) - no hierarchy (tric:gh) - narrower (h)
1239
        sort {
1240
        my $a_hier = $a->subfield('w') // q{}; $a_hier = 'gh' if $a_hier !~ /^[gh]$/;
1240
            # Sort broader (g) - no hierarchy (tric:gh) - narrower (h)
1241
        my $b_hier = $b->subfield('w') // q{}; $b_hier = 'gh' if $b_hier !~ /^[gh]$/;
1241
            my $a_hier = $a->subfield('w') // q{};
1242
1242
            $a_hier = 'gh' if $a_hier !~ /^[gh]$/;
1243
        # When hierarchy does not resolve, sort on $a
1243
            my $b_hier = $b->subfield('w') // q{};
1244
        $a_hier cmp $b_hier || $a->subfield('a') cmp $b->subfield('a');
1244
            $b_hier = 'gh' if $b_hier !~ /^[gh]$/;
1245
        } @fields;
1245
1246
            # When hierarchy does not resolve, sort on $a
1247
            $a_hier cmp $b_hier || $a->subfield('a') cmp $b->subfield('a');
1248
        } @fields
1249
    );
1246
}
1250
}
1247
1251
1248
=head2 GetAuthorizedHeading
1252
=head2 GetAuthorizedHeading
(-)a/t/db_dependent/AuthoritiesMarc.t (-1 / +1 lines)
Lines 401-406 subtest 'DelAuthority() tests' => sub { Link Here
401
401
402
subtest 'BuildSummary/_marc21_sort_hierarchy_alpha' => sub {
402
subtest 'BuildSummary/_marc21_sort_hierarchy_alpha' => sub {
403
    plan tests => 1;
403
    plan tests => 1;
404
404
    #$schema->storage->txn_begin;
405
    #$schema->storage->txn_begin;
405
    #t::lib::Mocks::mock_preference('marcflavour', 'MARC21');
406
    #t::lib::Mocks::mock_preference('marcflavour', 'MARC21');
406
407
407
- 

Return to bug 41685