From abe7467ae5f9341f2f5f9cad3b1a48724ed1a425 Mon Sep 17 00:00:00 2001 From: Bernardo Campos Date: Sun, 23 Mar 2025 12:29:29 -0300 Subject: [PATCH] Fix issue BookStackApp#5542 Sorting by name --- app/Sorting/SortSetOperationComparisons.php | 5 +++-- tests/Sorting/SortRuleTest.php | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/Sorting/SortSetOperationComparisons.php b/app/Sorting/SortSetOperationComparisons.php index e34652315..e506e9a13 100644 --- a/app/Sorting/SortSetOperationComparisons.php +++ b/app/Sorting/SortSetOperationComparisons.php @@ -2,6 +2,7 @@ namespace BookStack\Sorting; +use voku\helper\ASCII; use BookStack\Entities\Models\Chapter; use BookStack\Entities\Models\Entity; @@ -13,12 +14,12 @@ class SortSetOperationComparisons { public static function nameAsc(Entity $a, Entity $b): int { - return strtolower($a->name) <=> strtolower($b->name); + return strtolower(ASCII::to_transliterate($a->name)) <=> strtolower(ASCII::to_transliterate($b->name)); } public static function nameDesc(Entity $a, Entity $b): int { - return strtolower($b->name) <=> strtolower($a->name); + return strtolower(ASCII::to_transliterate($b->name)) <=> strtolower(ASCII::to_transliterate($a->name)); } public static function nameNumericAsc(Entity $a, Entity $b): int diff --git a/tests/Sorting/SortRuleTest.php b/tests/Sorting/SortRuleTest.php index e956f49df..b0f20cba5 100644 --- a/tests/Sorting/SortRuleTest.php +++ b/tests/Sorting/SortRuleTest.php @@ -198,6 +198,8 @@ class SortRuleTest extends TestCase $namesToAdd = [ "Beans", "bread", + "Éclaire", + "egg", "Milk", "pizza", "Tomato",