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-05-2023, 10:11 AM   #1
slb
Junior Member
slb began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Apr 2023
Device: none
Make composite column series_sort

I'll start with saying I have no programming background. And this is the first time I'm trying something like this in Calibre. First time posting here also.

I have several series with the same name. I want to have them sorted so they are directly behind eachother. But I want each language seperate.

I want to sort like this: series_sort -> language -> series_index

ex.: Talon by Julie Kagawa

What I want:

Talon [1] - Talon - Julie Kagawa - English
Talon [2] - Rogue - Julie Kagawa - English
...
Talon [1] - Pupil - Julie Kagawa - Dutch
Talon [2] - Rebel - Julie Kagawa - Dutch
...

What I get is:

Talon [1] - Talon - Julie Kagawa - English
Talon [1] - Pupil - Julie Kagawa - Dutch
Talon [2] - Rogue - Julie Kagawa - English
Talon [2] - Rebel - Julie Kagawa - Dutch
...
(Because when you sort, you only have the option series. You sort then by series_sort as well as series_index. You don't have the option to sort by series_sort.

I can make a new column series, but then it doesn't take the artikels into account, which is super annoying.

So to fix this I want to make a composite column series_sort. However I keep running into problems.

I have tried entering:
series_sort
series_sort()
{series_sort}
{series_sort()}

Please help!!

If you help, please do it step by step. Where I need to go, where I need to type in the data, best if I can do copy/paste. Because otherwise I have no idea or experience with templates and stuff.

I received this from one of the creators but I have absolutely no idea where I need to imput this. What I need to do.

program:
sort = series_sort();
lang = finish_formatting(language_strings($language, 1), '', ' - ', '');
if sort then
strcat(series_sort() & lang & ' - [' & $series_index & ']')
else
'No series'
fi

Thank you
slb is offline   Reply With Quote
Old 04-05-2023, 10:43 AM   #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,844
Karma: 54837878
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Sorts are always by priority (the order)
You sorted by series so Language is lower priority

If you want by Language ,That needs to be the last (most current sort in the Library view) . Calibre biases sort by the previous sort.
Sort by Title, then by Author and you will see that authors books in Title order.

Also, you can't have conflicting sorts (that work )
You can't sort by Title and series_index (unless it is the Alphabet Murders )
theducks is offline   Reply With Quote
Advert
Old 04-05-2023, 01:05 PM   #3
slb
Junior Member
slb began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Apr 2023
Device: none
Yes, I am aware of that but, what I'm wondering about is how to make a custom column series_sort (like you can do for author_sort). That would make of for example The Witcher, the value Witcher.

With view manager or sort by you can prioritise sorting, do multiple.

But because sorting of series is done immediately for both series_sort and series_index, the secundary sort has no effect other than putting Dutch/English/Dutch/English... or English/Dutch/English/Dutch (example previous post, what i get). And if I start to sort with language, then the series isn't grouped together anymore, there are then several large groupings of the same language.

To be able to get the grouping I want, I need to be able to sort like: high priority -> low
series_sort (custom column) -> languages -> series_index (custom column, this I know how to make)

Last edited by slb; 04-05-2023 at 01:07 PM.
slb is offline   Reply With Quote
Old 04-05-2023, 01:43 PM   #4
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,753
Karma: 7029857
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
I am the person who gave you the template. However, this thread provides information that is a bit different so here is a different answer. This time I am using Template Program Mode instead of General Program Mode in hopes that is easier for you to maintain.

First comment: you say that you want to sort on
series_sort -> language -> series_index
However, your examples include the author. Does the author really play no role in the sort? Assuming it doesn't, here is a template that gives you what you are asking for.
Code:
{:'series_sort()'|| - }{:'language_strings($language, 1)'}{series_index:0>5.2f| - |}
Notes:
  • If there is no series, the output begins with the language. If you want it can have it do something else, such as output the string "No Series" (in your language).
  • If there is no language then nothing is output for it.
  • If there is no series then no series index is output.
Result:
  • A book in Dutch with no series will show "Dutch".
  • Book 3 of series Talon with no language will show "Talon - 3"
  • A book with no language and no series will show "" (empty string).

This template outputs the words "No Series" if there isn't a series, and the words "No Language" if there isn't a language. If there is no series then it doesn't output a series index.
Code:
{:'ifempty(series_sort(), "No Series")'|| - }{:'ifempty(language_strings($language, 1), "No Language")'}{series_index:0>5.2f| - |}
It might be better to output something other than "No ..." to ensure that the books sort more consistently. Perhaps
Code:
{:'ifempty(series_sort(), "*")'|| - }{:'ifempty(language_strings($language, 1), "*")'}{series_index:0>5.2f| - |}
To use these templates you create a composite column (Column built from other columns, not Behaves like tags). Use whatever you want as the lookup name, the column heading, and the description. Paste one of the two above templates into the template box. Choose "Text" as the Sort/search kind. You may or may not want to check the Show in Tag browser box -- my guess is that you don't because no entry will in more than one book. Don't check Show as HTML. This screen capture shows what I mean.
Click image for larger version

Name:	Clipboard02.jpg
Views:	56
Size:	49.1 KB
ID:	200815

Personally I would use
series_sort -> language -> series_index -> Title
so that books with no series are not in what appears to be a random order, falling back to title. This template does that.
Code:
{:'ifempty(series_sort(), "*")'|| - }{:'ifempty(language_strings($language, 1), "*")'}{series_index:0>5.2f| - |} ({title})
chaley is offline   Reply With Quote
Old 04-05-2023, 03:01 PM   #5
slb
Junior Member
slb began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Apr 2023
Device: none
Hey Chaley

Thank you for the extra information, although I think it wasn't yet what I was searching for.

I found just a few minutes earlier a solution.

I did a custom column with this as argument: {series:swap_around_articles()}

And for the sorting of the articles in all languages to apply. I did as instructed in this post: https://www.mobileread.com/forums/sh...d.php?t=201578

Then I used View Manager to sort:
series_sort (custom column) -> languages -> series -> title

Last edited by slb; 04-05-2023 at 03:06 PM.
slb is offline   Reply With Quote
Advert
Old 04-05-2023, 03:09 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,753
Karma: 7029857
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by slb View Post
Hey Chaley

Thank you for the extra information. I found just a few minutes earlier a solution.

I did a custom column with this as argument: {series:swap_around_articles()}

And for the sorting of the articles in all languages to apply. I did as instructed in this post: https://www.mobileread.com/forums/sh...d.php?t=201578

Then I used View Manager to sort:
series_sort (custom column) -> languages -> series -> title
Hmmm... the template series_sort() function should use the book's language when computing the answer. If a book has more than one language then it should use either the first or the interface language. I will look at that.
chaley is offline   Reply With Quote
Old 04-09-2023, 12:52 PM   #7
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,753
Karma: 7029857
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by chaley View Post
Hmmm... the template series_sort() function should use the book's language when computing the answer. If a book has more than one language then it should use either the first or the interface language. I will look at that.
As of calibre 6.15 the series_sort() function uses the book's language.
chaley is offline   Reply With Quote
Reply

Tags
custom column, custom columns, series order, series organization, series sort


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
Composite Column BetterRed Calibre 12 09-01-2013 04:58 AM
Set value of another column from composite? dirgeon Library Management 1 02-03-2013 11:40 AM
Composite column or not ? Bertrand Library Management 3 08-24-2011 01:27 AM


All times are GMT -4. The time now is 09:29 AM.


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