From 5f1eefa403f5c3c2ee2fd85dd9e9d09d6ccfd236 Mon Sep 17 00:00:00 2001 From: The Minh Luong Date: Mon, 7 Mar 2022 11:29:30 -0500 Subject: [PATCH] Bug 29922: Sorting works for accents MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch sorts groups of libraries in alphabetical order, with the accents too. I've used the setlocale() function to set the ordering for comparison (LC_COLLATE) to the one used in french language. TO TEST: 1. Follow the steps in the previous patch NOTE: Have some groups of libraries that starts with accented letters (ex. ÉGroup, ÄGroup, ...) 2. Go in the OPAC, then Advanced search and click on the "Groups of libraries" dropdown. 3. Notice that the groups are sorted in alphabetical order. NOTE: Accented groups are sorted too ! Although this patch can sort the groups as described, I have read that locale might not be available on all computers. --- opac/opac-search.pl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/opac/opac-search.pl b/opac/opac-search.pl index 04cf839b27..ebf503fa04 100755 --- a/opac/opac-search.pl +++ b/opac/opac-search.pl @@ -216,8 +216,11 @@ if ($cgi->cookie("search_path_code")) { } } +use POSIX qw(locale_h); +use locale; +setlocale(LC_COLLATE, "fr_CA.UTF-8"); my @search_groups = Koha::Library::Groups->get_search_groups( { interface => 'opac' } )->as_list; -@search_groups = sort { $a->title cmp $b->title } @search_groups; +@search_groups = sort { lc($a->title) cmp lc($b->title) } @search_groups; $template->param( search_groups => \@search_groups ); # load the language limits (for search) -- 2.25.1