mattttvaughn / chronicle

GNU General Public License v3.0
217 stars 60 forks source link

Handling numbers in titles when sorting #21

Open mattttvaughn opened 2 years ago

mattttvaughn commented 2 years ago

In the library view, books ought to be sorted like the following (numbers sorted by number order):

 - Series Name - Book 1 - Title
 - Series Name - Book 2 - Title
 - Series Name - Book 3 - Title
...
 - Series Name - Book 10 - Title
 - Series Name - Book 11 - Title

They are currently sorted like so:

 - Series Name - Book 1 - Title
 - Series Name - Book 10 - Title
 - Series Name - Book 11 - Title
...
 - Series Name - Book 19 - Title
 - Series Name - Book 2 - Title
 - Series Name - Book 20 - Title
 - Series Name - Book 21 - Title

This can be remedied by sorting by "natural order" instead of of by default string order. Natural sort in kotlin:

https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.comparisons/natural-order.html

As of writing this ticket, sorting currently happens in LibraryViewModel

mattttvaughn commented 2 years ago

Original report on the reddit: https://www.reddit.com/r/ChronicleApp/comments/rgahts/not_properly_sorting_books_by_title/