Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 04-18-2023, 01:02 PM   #1
isarl
Addict
isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.
 
Posts: 287
Karma: 2534928
Join Date: Nov 2022
Location: Canada
Device: Kobo Aura 2
Feature?/Help request: Sorting composite column by a different column's value

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!
isarl is offline   Reply With Quote
Old 04-18-2023, 01:16 PM   #2
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 29,919
Karma: 55705262
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Why not just move the subtitle column to be next to Title? No need to bloat the DB (performance hit).

Title follows the sort order scheme in ID: title_series_sorting
A calculated column does not have a tweak.

BTW Preferences:Look&Feel:Book Details (sidebar) is where you also do this to get the details to be the same order
theducks is offline   Reply With Quote
Advert
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: 11,770
Karma: 7029857
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:	109
Size:	34.0 KB
ID:	201116
chaley is offline   Reply With Quote
Old 04-18-2023, 03:47 PM   #4
isarl
Addict
isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.
 
Posts: 287
Karma: 2534928
Join Date: Nov 2022
Location: Canada
Device: Kobo Aura 2
Your comments are both full of helpful suggestions – thank you both very much!

Quote:
Originally Posted by theducks View Post
Why not just move the subtitle column to be next to Title? No need to bloat the DB (performance hit).

Title follows the sort order scheme in ID: title_series_sorting
A calculated column does not have a tweak.

BTW Preferences:Look&Feel:Book Details (sidebar) is where you also do this to get the details to be the same order
1) Sure, could do. This is a matter of personal taste – I like keeping the parts as separate metadata but displaying them as a single field.

2) Always good to know about more tweaks, but in this case I'm happy to leave it on library_order.

3) This is very helpful too; I used this feature to hide the Title and Subtitle fields from Book Details and put my composite column in their place before any of the other fields.

Quote:
Originally Posted by chaley View Post
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.
No worries, I appreciate that just because a request is able to be simply phrased, that doesn't mean it's always trivial to implement.

Quote:
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 ...
    Attachment 201116
1) Nice, simple suggestion. Since I'm mostly using this for aesthetic purposes I prefer not to take it, but that doesn't undercut its simplicity or relevance.

2) Oh my gosh, there's a Sort By action. Which now lives on my search toolbar next to Saved Searches and Mark Books. (For anybody reading who didn't know you can customize your toolbars and menus, see Preferences > Interface > Toolbars & menus. I chose “The buttons on the search bar” to which I added “Sort by”.) This is perfect, exactly what I needed. I can sort by Title > Subtitle and I can save the sort as well, totally independently of my custom composite column.

3) This is great and with Action Chains I guess its usefulness is only limited by one's creativity. Nevertheless, Sort By solves my issue so well that this would be overkill for me here, but it's still very informative.

Thanks again!

Last edited by isarl; 04-18-2023 at 03:51 PM.
isarl is offline   Reply With Quote
Old 04-18-2023, 04:00 PM   #5
isarl
Addict
isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.isarl ought to be getting tired of karma fortunes by now.
 
Posts: 287
Karma: 2534928
Join Date: Nov 2022
Location: Canada
Device: Kobo Aura 2
One last comment, now that I've played with “Sort by” a little bit: if I were doing this frequently, using the “Sort on multiple columns” dialogue over and over, even to load a saved sort, is a bit clunky. In that case, I think a winning idea would be to combine Charles's first and second suggestions – make a new composite column using title_sort instead of title, and choose it from the “Sort by” dropdown.

In practice, I think I change my sorting pretty infrequently. Nevertheless, I thought I'd share that idea in case it helps anybody else.
isarl is offline   Reply With Quote
Advert
Old 04-18-2023, 04:07 PM   #6
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: 11,770
Karma: 7029857
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by isarl View Post
One last comment, now that I've played with “Sort by” a little bit: if I were doing this frequently, using the “Sort on multiple columns” dialogue over and over, even to load a saved sort, is a bit clunky. In that case, I think a winning idea would be to combine Charles's first and second suggestions – make a new composite column using title_sort instead of title, and choose it from the “Sort by” dropdown.

In practice, I think I change my sorting pretty infrequently. Nevertheless, I thought I'd share that idea in case it helps anybody else.
I just submitted changes for Kovid's review that adds saved sorts to the top-level menu. That makes them as easy to get to as columns. I will post here if he accepts the changes.
Attached Thumbnails
Click image for larger version

Name:	Clipboard01.jpg
Views:	62
Size:	28.8 KB
ID:	201118  
chaley is offline   Reply With Quote
Old 04-18-2023, 04:33 PM   #7
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 8,760
Karma: 62032371
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
On somewhat the same topic, I've had to create custom columns just to sort series-columns. If you sort ascending, undefineds go first. But if you sort descending, the series are in reverse order. So I sort series first, then sort a composite order checking that the column has a value to make them go to the top.

View Manager is a bit of a help. It's unfortunate that it can't do a sorting-only view and leaving the columns unchanged.

Last edited by ownedbycats; 04-18-2023 at 04:38 PM.
ownedbycats is offline   Reply With Quote
Old 04-18-2023, 05:01 PM   #8
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 20,648
Karma: 26960534
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Quote:
Originally Posted by ownedbycats View Post
View Manager is a bit of a help. It's unfortunate that it can't do a sorting-only view and leaving the columns unchanged.
Maybe the Sort By tool can help.

BR
BetterRed is online now   Reply With Quote
Old 04-18-2023, 05:25 PM   #9
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: 11,770
Karma: 7029857
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
On somewhat the same topic, I've had to create custom columns just to sort series-columns. If you sort ascending, undefineds go first. But if you sort descending, the series are in reverse order. So I sort series first, then sort a composite order checking that the column has a value to make them go to the top.
Why use two columns? Instead make the composite generate values that sort the way you want, using something like ZZZZZZ for undefined values.
Quote:
View Manager is a bit of a help. It's unfortunate that it can't do a sorting-only view and leaving the columns unchanged.
Quote:
Originally Posted by BetterRed View Post
Maybe the Sort By tool can help.

BR
Yes, especially if the changes I submitted are accepted. At that point you will be able to use Action Chains to invoke a saved sort with a keyboard shortcut, or add the sort to Favourites. And before you ask, no, I am not interested in adding shortcuts to sorts in the "Sort by" tool. If someone wants this enough then develop a "Sort by" plugin that does the job.

For some reason one must click the "Sort by" button before Action Chains or Favourites can "see" the menus.
chaley is offline   Reply With Quote
Old 04-18-2023, 05:42 PM   #10
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 8,760
Karma: 62032371
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Then the 'ZZZZZZ' would show up in the column, lol. I suppose I could hide it with a column icon though (I do this for Unknown authors)
ownedbycats is offline   Reply With Quote
Old 04-18-2023, 05:44 PM   #11
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: 11,770
Karma: 7029857
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by ownedbycats View Post
Then the 'ZZZZZZ' would show up in the column, lol. I suppose I could hide it with a column icon though (I do this when author is 'Unknown').
You don't need to show a column in the book list to sort on it.
chaley is offline   Reply With Quote
Old 04-18-2023, 05:50 PM   #12
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 8,760
Karma: 62032371
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Oh, I get it now. Ill experiment a bit.
ownedbycats is offline   Reply With Quote
Old 04-18-2023, 06:30 PM   #13
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 20,648
Karma: 26960534
Join Date: Mar 2012
Location: Sydney Australia
Device: none
Quote:
Originally Posted by chaley View Post
Yes, especially if the changes I submitted are accepted. At that point you will be able to use Action Chains to invoke a saved sort with a keyboard shortcut, or add the sort to Favourites. And before you ask, no, I am not interested in adding shortcuts to sorts in the "Sort by" tool. If someone wants this enough then develop a "Sort by" plugin that does the job.
Adding Saved Sorts to Favourites

BR
BetterRed is online now   Reply With Quote
Old 04-19-2023, 12:28 AM   #14
Terisa de morgan
Grand Sorcerer
Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.
 
Terisa de morgan's Avatar
 
Posts: 6,261
Karma: 11768331
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
Quote:
Originally Posted by isarl View Post
2) Oh my gosh, there's a Sort By action. Which now lives on my search toolbar next to Saved Searches and Mark Books. (For anybody reading who didn't know you can customize your toolbars and menus, see Preferences > Interface > Toolbars & menus. I chose “The buttons on the search bar” to which I added “Sort by”.) This is perfect, exactly what I needed. I can sort by Title > Subtitle and I can save the sort as well, totally independently of my custom composite column.
Thank you! I didn't and now I've added to the buttons.
Terisa de morgan is offline   Reply With Quote
Old 04-19-2023, 06:13 AM   #15
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: 11,770
Karma: 7029857
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by chaley View Post
I just submitted changes for Kovid's review that adds saved sorts to the top-level menu. That makes them as easy to get to as columns. I will post here if he accepts the changes.
These changes are now in calibre source.
chaley is offline   Reply With Quote
Reply

Tags
custom column, sorting


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with a composite column ownedbycats Library Management 2 07-08-2020 10:06 AM
Need help with composite column BookJunkieLI Library Management 2 07-03-2019 11:42 AM
Feature Request: Lock Column CRussel Calibre 31 02-11-2018 03:25 AM
Sorting/searching composite column causes slow startup [solved] capnm Library Management 0 11-08-2011 11:44 AM
Composite column or not ? Bertrand Library Management 3 08-24-2011 01:27 AM


All times are GMT -4. The time now is 08:06 PM.


MobileRead.com is a privately owned, operated and funded community.