[Enhancement] Support natural sorting of titles #1508

Open
opened 2026-04-24 23:48:03 +02:00 by adam · 14 comments
Owner

Originally created by @plusmaa on GitHub (Nov 3, 2023).

Describe the issue

After updating my Docker Container to latest Version, when Media has a Number like 1. or 2. and so on in front of the name the sorting by title inside Library looks like this: 1. 10. 100. 101. and so on.
Is this a bug or a feature? I cant find a setting to change it and before the update it worked correctly.

Steps to reproduce the issue

  1. Import Media with Numbers in front of the Title like 1. 2. or 100. or what ever
  2. Sort Media in Library by Title

Audiobookshelf version

2.5.0

How are you running audiobookshelf?

Docker

Originally created by @plusmaa on GitHub (Nov 3, 2023). ### Describe the issue After updating my Docker Container to latest Version, when Media has a Number like 1. or 2. and so on in front of the name the sorting by title inside Library looks like this: 1. 10. 100. 101. and so on. Is this a bug or a feature? I cant find a setting to change it and before the update it worked correctly. ### Steps to reproduce the issue 1. Import Media with Numbers in front of the Title like 1. 2. or 100. or what ever 2. Sort Media in Library by Title ### Audiobookshelf version 2.5.0 ### How are you running audiobookshelf? Docker
adam added the enhancementsorting/filtering/searching labels 2026-04-24 23:48:03 +02:00
Author
Owner

@advplyr commented on GitHub (Nov 3, 2023):

In server v2.4.x the API is querying directly from the sqlite db. Sqlite doesn't support natural sorting out of the box.
This thread has some ideas on how to implement it: https://sqlite.org/forum/forumpost/cff93834d2
but it doesn't seem like a quick add.

I'll switch this to a feature request for now

@advplyr commented on GitHub (Nov 3, 2023): In server v2.4.x the API is querying directly from the sqlite db. Sqlite doesn't support natural sorting out of the box. This thread has some ideas on how to implement it: https://sqlite.org/forum/forumpost/cff93834d2 but it doesn't seem like a quick add. I'll switch this to a feature request for now
Author
Owner

@advplyr commented on GitHub (Nov 3, 2023):

An additional note on this is that if we can get natural sorting in sqlite then we can continue allowing alphanumeric series sequence. At the moment we support alphanumeric but it won't sort correctly.

@advplyr commented on GitHub (Nov 3, 2023): An additional note on this is that if we can get natural sorting in sqlite then we can continue allowing alphanumeric series sequence. At the moment we support alphanumeric but it won't sort correctly.
Author
Owner

@plusmaa commented on GitHub (Nov 3, 2023):

i now went back to 2.3.5 but the sorting is still not natural. do i have to delete my config or something like that?

@plusmaa commented on GitHub (Nov 3, 2023): i now went back to 2.3.5 but the sorting is still not natural. do i have to delete my config or something like that?
Author
Owner

@plusmaa commented on GitHub (Dec 23, 2023):

can someone explain how i can go back to a version with natural sorting?
most of my podcasts and audiobooks come in series with numbers. this makes using audiobookshelf really unpractical.

@plusmaa commented on GitHub (Dec 23, 2023): can someone explain how i can go back to a version with natural sorting? most of my podcasts and audiobooks come in series with numbers. this makes using audiobookshelf really unpractical.
Author
Owner

@advplyr commented on GitHub (Dec 23, 2023):

Is there a reason you aren't using the series sequence input and the episode pubdate? Those are used for sorting

@advplyr commented on GitHub (Dec 23, 2023): Is there a reason you aren't using the series sequence input and the episode pubdate? Those are used for sorting
Author
Owner

@plusmaa commented on GitHub (Dec 23, 2023):

episode pubdate does not work because there are a lot rereleases of the audiobook.
i didnt think of using series sequence yet. i can use this but i would have to do it manually for 300 episodes as this is not provided by the google books metadata. i guess i will do this anyway.
thank you.

@plusmaa commented on GitHub (Dec 23, 2023): episode pubdate does not work because there are a lot rereleases of the audiobook. i didnt think of using series sequence yet. i can use this but i would have to do it manually for 300 episodes as this is not provided by the google books metadata. i guess i will do this anyway. thank you.
Author
Owner

@r748 commented on GitHub (Jan 2, 2024):

I'm running into the same problem. The titles of my 200+ audiobooks in a collection are like "Episode X:

@r748 commented on GitHub (Jan 2, 2024): I'm running into the same problem. The titles of my 200+ audiobooks in a collection are like "Episode X: <Title>" whereas X represents the sequence number of the respective episode. It would really be nice to have the titles sorted correctly from Episode 1 to Episode 224, instead of 100, ..., 109, 10, 110, ...etc.. Thanks!
Author
Owner

@advplyr commented on GitHub (Jan 2, 2024):

I was confused by the term "Episode" because that is what we use for podcasts.

If the folder structure is followed from the website it will pull in the sequence automatically: https://www.audiobookshelf.org/docs#book-directory-structure

Or you can use the Match and quick match features to quickly fill it in if it is in audible

@advplyr commented on GitHub (Jan 2, 2024): I was confused by the term "Episode" because that is what we use for podcasts. If the folder structure is followed from the website it will pull in the sequence automatically: https://www.audiobookshelf.org/docs#book-directory-structure Or you can use the Match and quick match features to quickly fill it in if it is in audible
Author
Owner

@r748 commented on GitHub (Jan 4, 2024):

@advplyr Thanks for the input. I batch changed the folder naming and now the "Series" view is showing the correct order.

@r748 commented on GitHub (Jan 4, 2024): @advplyr Thanks for the input. I batch changed the folder naming and now the "Series" view is showing the correct order.
Author
Owner

@illmouse commented on GitHub (Nov 10, 2024):

Hi everyone!

I can see that's a pretty old thread, but I got bumped in to this when tried to import manga CBZ collection. Turned out that sorting for audio files differs from CBZ files.

It's naturally for manga to have very long series (1000+) books placed in separate CBZ files and when I'm importing such series they are sorted like 01 10 11 12 .. 2 3 etc.

Is there is a way to get it right in audiobookshelf?

And by right I mean 1 2 3 .. 10 11 12 .. 20 and so on.

Would appreciate any assistance on this matter.

Thanks in advance!

For reference how it looks:
image

@illmouse commented on GitHub (Nov 10, 2024): Hi everyone! I can see that's a pretty old thread, but I got bumped in to this when tried to import manga CBZ collection. Turned out that sorting for audio files differs from CBZ files. It's naturally for manga to have very long series (1000+) books placed in separate CBZ files and when I'm importing such series they are sorted like 01 10 11 12 .. 2 3 etc. Is there is a way to get it right in audiobookshelf? And by right I mean 1 2 3 .. 10 11 12 .. 20 and so on. Would appreciate any assistance on this matter. Thanks in advance! For reference how it looks: ![image](https://github.com/user-attachments/assets/8e521741-93ff-456e-9712-36cb9f058fb8)
Author
Owner

@advplyr commented on GitHub (Nov 11, 2024):

Comic series like that are not going to work well with Abs right now because Abs expects each comic file to be in its own folder.

You may want to wait until better support is added for comic folder structures. You can follow https://github.com/advplyr/audiobookshelf/issues/2338

@advplyr commented on GitHub (Nov 11, 2024): Comic series like that are not going to work well with Abs right now because Abs expects each comic file to be in its own folder. You may want to wait until better support is added for comic folder structures. You can follow https://github.com/advplyr/audiobookshelf/issues/2338
Author
Owner

@illmouse commented on GitHub (Nov 11, 2024):

@advplyr, thank you for your response! Followed #2338 , will be monitoring this feature. A long the way I discovered that history is tracked only for the primary book and though I can manually read each volume, progress on these volumes wont be tracked.

I'm going to use Kavita for now, but will hope for implementation of this feature in future. It would be very convenient to have all things in one app.

Thanks again!

@illmouse commented on GitHub (Nov 11, 2024): @advplyr, thank you for your response! Followed #2338 , will be monitoring this feature. A long the way I discovered that history is tracked only for the primary book and though I can manually read each volume, progress on these volumes wont be tracked. I'm going to use Kavita for now, but will hope for implementation of this feature in future. It would be very convenient to have all things in one app. Thanks again!
Author
Owner

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

Heyy, sorry for waking up this thread, just stumbled upon this, after trying to find a solution for the same issue :/

Just wanted to ask, as the issue is from SQL and that'd just be a PITA to implement then; Would it, instead, be possible to add "Sorting Names"? For example, when choosing a Series Name, maybe add another input like this:

Image

That way, people could customize the sorting, even alphanumerically, without needing to rework the way SQL handles anything?

Thanks in advance!

@holyarahippo06 commented on GitHub (Apr 2, 2025): Heyy, sorry for waking up this thread, just stumbled upon this, after trying to find a solution for the same issue :/ Just wanted to ask, as the issue is from SQL and that'd just be a PITA to implement then; Would it, instead, be possible to add "Sorting Names"? For example, when choosing a Series Name, maybe add another input like this: ![Image](https://github.com/user-attachments/assets/24af02e7-c85b-48bf-b8c5-8bf57fa923c5) That way, people could customize the sorting, even alphanumerically, without needing to rework the way SQL handles anything? Thanks in advance!
Author
Owner

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

Heyy, sorry for waking up this thread, just stumbled upon this, after trying to find a solution for the same issue :/

Just wanted to ask, as the issue is from SQL and that'd just be a PITA to implement then; Would it, instead, be possible to add "Sorting Names"? For example, when choosing a Series Name, maybe add another input like this:

Yeah I think it is a good idea and there are existing feature requests open for it.
I found one https://github.com/advplyr/audiobookshelf/issues/1074 but I'm sure there are others. For author names also.

I think we should do this and replace the "Sorting ignore prefix" setting with settings/logic for pre-populating the sort titles.
This is a big project though.

@advplyr commented on GitHub (Apr 2, 2025): > Heyy, sorry for waking up this thread, just stumbled upon this, after trying to find a solution for the same issue :/ > > Just wanted to ask, as the issue is from SQL and that'd just be a PITA to implement then; Would it, instead, be possible to add "Sorting Names"? For example, when choosing a Series Name, maybe add another input like this: Yeah I think it is a good idea and there are existing feature requests open for it. I found one https://github.com/advplyr/audiobookshelf/issues/1074 but I'm sure there are others. For author names also. I think we should do this and replace the "Sorting ignore prefix" setting with settings/logic for pre-populating the sort titles. This is a big project though.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#1508