Sorting by name not working with "É" #5228

Closed
opened 2026-02-05 09:50:14 +03:00 by OVERLORD · 2 comments
Owner

Originally created by @serinf-lauza on GitHub (Mar 18, 2025).

Describe the Bug

Hi! I created a sorting rule that only has Name - Alphabetical (Asc) in it. When I apply it to a book, the letter "É" gets sort out at the end of everything. It should be between "D" and "F", the previous method for sorting by name still works and put it as it's rightful place (Sort by name). My BookStack is in French, so we use a lot of "É" in our titles!
Thank you! :)

Steps to Reproduce

  1. Settings > Sorting
  2. Create a rule with Name - Alphabetical (Asc)
  3. Choose the Auto sort Option created previously to sort a chapter
  4. See where "É" goes

Image

Expected Behaviour

It should be between "D" and "F" when sorted by name.

Screenshots or Additional Context

No response

Browser Details

Chrome

Exact BookStack Version

v25.02.1

Originally created by @serinf-lauza on GitHub (Mar 18, 2025). ### Describe the Bug Hi! I created a sorting rule that only has Name - Alphabetical (Asc) in it. When I apply it to a book, the letter "É" gets sort out at the end of everything. It should be between "D" and "F", the previous method for sorting by name still works and put it as it's rightful place (Sort by name). My BookStack is in French, so we use a lot of "É" in our titles! Thank you! :) ### Steps to Reproduce 1. Settings > Sorting 2. Create a rule with Name - Alphabetical (Asc) 3. Choose the Auto sort Option created previously to sort a chapter 4. See where "É" goes ![Image](https://github.com/user-attachments/assets/99cb8676-7417-43e4-adfa-7e73ac94af1e) ### Expected Behaviour It should be between "D" and "F" when sorted by name. ### Screenshots or Additional Context _No response_ ### Browser Details Chrome ### Exact BookStack Version v25.02.1
OVERLORD added the 🐛 Bug label 2026-02-05 09:50:14 +03:00
Author
Owner

@bernardo-campos commented on GitHub (Mar 23, 2025):

In BookStack\Sorting\SortSetOperationComparisons, the nameAsc and nameDesc functions use:

return strtolower($a->name) <=> strtolower($b->name);

The <=> operator combined with strtolower() doesn’t reliably handle accented characters across all configurations. For example, it might sort "é" after "z" leading to inconsistent results in languages like Spanish or French.

Using Collator from the intl extension would be more appropriate, as it offers locale-aware comparisons for accurate and culturally correct sorting of accented characters.

I’m working on a PR to address this.

@bernardo-campos commented on GitHub (Mar 23, 2025): In `BookStack\Sorting\SortSetOperationComparisons`, the `nameAsc` and `nameDesc` functions use: `return strtolower($a->name) <=> strtolower($b->name);` The `<=>` operator combined with `strtolower()` doesn’t reliably handle accented characters across all configurations. For example, it might sort "é" after "z" leading to inconsistent results in languages like Spanish or French. Using `Collator` from the **intl extension** would be more appropriate, as it offers locale-aware comparisons for accurate and culturally correct sorting of accented characters. I’m working on a PR to address this.
Author
Owner

@ssddanbrown commented on GitHub (Apr 2, 2025):

Thanks to the work done by @bernardo-campos in #5550 this has now been improved, with the applied changes due to be part of the next patch release.

Thanks @serinf-lauza for raising.

@ssddanbrown commented on GitHub (Apr 2, 2025): Thanks to the work done by @bernardo-campos in #5550 this has now been improved, with the applied changes due to be part of the next patch release. Thanks @serinf-lauza for raising.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#5228