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

(-)a/Koha/SearchEngine/Elasticsearch/Search.pm (-3 / +14 lines)
Lines 54-59 use MARC::File::XML; Link Here
54
use MIME::Base64 qw( decode_base64 );
54
use MIME::Base64 qw( decode_base64 );
55
use JSON;
55
use JSON;
56
56
57
use POSIX qw(setlocale LC_COLLATE);
58
use Unicode::Collate::Locale;
59
57
Koha::SearchEngine::Elasticsearch::Search->mk_accessors(qw( store ));
60
Koha::SearchEngine::Elasticsearch::Search->mk_accessors(qw( store ));
58
61
59
=head2 search
62
=head2 search
Lines 504-511 sub _convert_facets { Link Here
504
            };
507
            };
505
        }
508
        }
506
        if( C4::Context->preference('FacetOrder') eq 'Alphabetical' ){
509
        if( C4::Context->preference('FacetOrder') eq 'Alphabetical' ){
507
            @{ $facet->{facets} } =
510
            #Fetch locale as understood by Perl
508
                sort { $a->{facet_label_value} cmp $b->{facet_label_value} } @{ $facet->{facets} };
511
            #NOTE: Technically, we can define locale however we like, but this
512
            #is a good default
513
            my $locale = setlocale(LC_COLLATE);
514
515
            #Create locale-based collator
516
            my $collator = Unicode::Collate::Locale->new( locale => $locale );
517
            if ($collator) {
518
                @{ $facet->{facets} } =
519
                    sort { $collator->cmp( $a->{facet_label_value}, $b->{facet_label_value} ) } @{ $facet->{facets} };
520
            }
509
        }
521
        }
510
        push @facets, $facet if exists $facet->{facets};
522
        push @facets, $facet if exists $facet->{facets};
511
    }
523
    }
512
- 

Return to bug 36947