View Single Post
Old 04-18-2023, 03:18 PM   #3
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,485
Karma: 8025704
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by isarl View Post
I store Title separately from Subtitle, but in my main library view I display both using a composite column, separating them with a colon if the subtitle is set: {title}{#subtitle:|: |}

However, when sorting by this field, The Memory Librarian gets sorted next to other “The” titles, not next to titles starting with “Mem”.

For my purposes, it would be nice to have another option in the custom column settings for the “Sort/search column by” drop-down. Maybe “custom” and the ability to provide my own template. Then I could use something like {title_sort}{#subtitle:|: |} to have this field behave very similarly to the built-in title field.

Maybe I'm doing something silly and there's a better way to achieve what I'm after – I welcome suggestions. Thank you for reading!
The option to have a second template for sorting is difficult. Fetching the value of a column is done without knowing what use will be made of it. Changing that would require deep changes in the calibre db layer, and I can't say with confidence that it would work well even with the changes. It is definitely not worth the effort for me.

Other than @theducks suggestion, you could:
  • Use title_sort instead of title in your template. Of course you would see the altered title, but that might be OK.
  • Use the "Sort by" action to construct the multi-column sort you want, title then subtitle. Save this sort for later recall. I think it should offer any saved sorts in the main menu. I will look at whether this is feasible.
  • Use Action Chains: make a Python code action that sorts the way you want. Give it a keyboard shortcut. Example:
    Code:
    def run(gui, settings, chain):
        # Enter you code here
        gui.library_view.multisort((('title', True), ('#subtitle', True)))
    True means ascending. You could make two chains if you want to sort both ways.

    Here is the chain definition. Not much ...
    Click image for larger version

Name:	Clipboard01.jpg
Views:	208
Size:	34.0 KB
ID:	201116
chaley is offline   Reply With Quote