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 02-12-2023, 10:17 PM   #1
culytera
Zealot
culytera ought to be getting tired of karma fortunes by now.culytera ought to be getting tired of karma fortunes by now.culytera ought to be getting tired of karma fortunes by now.culytera ought to be getting tired of karma fortunes by now.culytera ought to be getting tired of karma fortunes by now.culytera ought to be getting tired of karma fortunes by now.culytera ought to be getting tired of karma fortunes by now.culytera ought to be getting tired of karma fortunes by now.culytera ought to be getting tired of karma fortunes by now.culytera ought to be getting tired of karma fortunes by now.culytera ought to be getting tired of karma fortunes by now.
 
Posts: 125
Karma: 295674
Join Date: Jul 2021
Device: iPhone
Proper alphanumerical sorting on tag browser

Hello! I made a template function to group word counts by certain thresholds and used it for a custom column where the results are shown on the tag browser, but they're not being sorted properly on the tag browser. It seems to only see the first digit on 5000, 10000, etc. The custom columns are already sorted by text. Same case for tags with numbers though I'm not sure if that's the intended behavior.

This is the template function with the template name getWordCountGroup.
Code:
program:
	getWordCount = field('#ao3_words');
	wordCount = re(getWordCount, '[,]', '');
	first_non_empty(
		cmp(wordCount, 5001,  'Less than 5000', '', ''),
		cmp(wordCount, 10001, 'Less than 10000', '', ''),
		cmp(wordCount, 20001, 'Less than 20000', '', ''),
		cmp(wordCount, 40001, 'Less than 40000', '', ''),
		cmp(wordCount, 80001, 'Less than 80000', '', ''),
		'Over 80000'
);
Attached Thumbnails
Click image for larger version

Name:	wordcount.jpg
Views:	111
Size:	245.1 KB
ID:	199704   Click image for larger version

Name:	tags.jpg
Views:	113
Size:	28.2 KB
ID:	199705  
culytera is offline   Reply With Quote
Old 02-14-2023, 12:07 AM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 45,363
Karma: 27230406
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
I doubt the tag browser sorting recognizes numbers inside text fields when sorting. It would be a significant performance hit.
kovidgoyal is offline   Reply With Quote
Advert
Old 02-14-2023, 12:17 AM   #3
culytera
Zealot
culytera ought to be getting tired of karma fortunes by now.culytera ought to be getting tired of karma fortunes by now.culytera ought to be getting tired of karma fortunes by now.culytera ought to be getting tired of karma fortunes by now.culytera ought to be getting tired of karma fortunes by now.culytera ought to be getting tired of karma fortunes by now.culytera ought to be getting tired of karma fortunes by now.culytera ought to be getting tired of karma fortunes by now.culytera ought to be getting tired of karma fortunes by now.culytera ought to be getting tired of karma fortunes by now.culytera ought to be getting tired of karma fortunes by now.
 
Posts: 125
Karma: 295674
Join Date: Jul 2021
Device: iPhone
One workaround I can do is adding a space before 5000 so it gets placed at the top of the list.
Attached Thumbnails
Click image for larger version

Name:	workaround.jpg
Views:	85
Size:	33.7 KB
ID:	199734  
culytera is offline   Reply With Quote
Old 02-14-2023, 12:18 PM   #4
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: 10,981
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Quote:
Originally Posted by kovidgoyal View Post
I doubt the tag browser sorting recognizes numbers inside text fields when sorting. It would be a significant performance hit.
Oddly enough, my purchase cost column does.

Click image for larger version

Name:	2023-02-14 13_17_47-Window.png
Views:	167
Size:	8.0 KB
ID:	199742

Template:
Spoiler:

Code:
program:
	switch_if(
		$$#purchasecost == 'none', '',
		$$#purchasecost ==# '00.00', '$0.00',
		$$#purchasecost <=# '00.99', '$0.01 - $0.99',
		$$#purchasecost <=# '04.99', '$1.00 - $4.99',
		$$#purchasecost <=# '10.00', '$5.00 - $9.99',
		$$#purchasecost <=# '15.00', '$10.00 - $14.99',
		$$#purchasecost <=# '15.00', '$10.00 - $14.99',
		$$#purchasecost <=# '20.00', '$15.00 - $19.99',
		$$#purchasecost <=# '30.00', '$20.00 - $29.99',
		'$30.00 and up' 
	)
ownedbycats is online now   Reply With Quote
Old 02-14-2023, 12:33 PM   #5
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: 31,064
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by ownedbycats View Post
Oddly enough, my purchase cost column does.

Attachment 199742

Template:
Spoiler:

Code:
program:
	switch_if(
		$$#purchasecost == 'none', '',
		$$#purchasecost ==# '00.00', '$0.00',
		$$#purchasecost <=# '00.99', '$0.01 - $0.99',
		$$#purchasecost <=# '04.99', '$1.00 - $4.99',
		$$#purchasecost <=# '10.00', '$5.00 - $9.99',
		$$#purchasecost <=# '15.00', '$10.00 - $14.99',
		$$#purchasecost <=# '15.00', '$10.00 - $14.99',
		$$#purchasecost <=# '20.00', '$15.00 - $19.99',
		$$#purchasecost <=# '30.00', '$20.00 - $29.99',
		'$30.00 and up' 
	)
Because that is a Numeric field and the other is Alpha-numeric. the sort/alignment is natively different, which is why we pad series index in templates
theducks is offline   Reply With Quote
Advert
Old 02-14-2023, 12:37 PM   #6
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: 10,981
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Quote:
Originally Posted by theducks View Post
Because that is a Numeric field and the other is Alpha-numeric. the sort/alignment is natively different, which is why we pad series index in templates
It's a composite column, sorted by text.
Attached Thumbnails
Click image for larger version

Name:	2023-02-14 13_37_49-Edit custom column.png
Views:	109
Size:	14.2 KB
ID:	199743  
ownedbycats is online now   Reply With Quote
Old 02-14-2023, 01:08 PM   #7
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: 31,064
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Quote:
Originally Posted by ownedbycats View Post
It's a composite column, sorted by text.
That is an Alpha-numeric sort (most characters on a keyboard)
Numeric has 2 general modes: Integer and Floating Point
Integer has no exponent or decimal, although it can be signed -32,767
theducks is offline   Reply With Quote
Old 02-19-2023, 10:21 PM   #8
culytera
Zealot
culytera ought to be getting tired of karma fortunes by now.culytera ought to be getting tired of karma fortunes by now.culytera ought to be getting tired of karma fortunes by now.culytera ought to be getting tired of karma fortunes by now.culytera ought to be getting tired of karma fortunes by now.culytera ought to be getting tired of karma fortunes by now.culytera ought to be getting tired of karma fortunes by now.culytera ought to be getting tired of karma fortunes by now.culytera ought to be getting tired of karma fortunes by now.culytera ought to be getting tired of karma fortunes by now.culytera ought to be getting tired of karma fortunes by now.
 
Posts: 125
Karma: 295674
Join Date: Jul 2021
Device: iPhone
I still don't understand the difference between mine and ownedbycats'. I've even changed the template to use switchif(). Same result for either composite column type.

The word count column the template is taking values from is an Integer type with the format {:,d}


Spoiler:
Code:
program:
	switch_if(
		$$#ao3_words <=# '5000',  '0 - 5000',
		$$#ao3_words <=# '10000', '5001 - 10000',
		$$#ao3_words <=# '20000', '10001 - 20000',
		$$#ao3_words <=# '40000', '20001 - 40000',
		$$#ao3_words <=# '80000', '40001 - 80000',
		'80000+' 
	)
Attached Thumbnails
Click image for larger version

Name:	wordcount_switchif.jpg
Views:	109
Size:	110.2 KB
ID:	199822  
culytera is offline   Reply With Quote
Old 02-20-2023, 06:35 AM   #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: 12,447
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Is this option checked in Preferences / Behavior?
Attached Thumbnails
Click image for larger version

Name:	Clipboard01.jpg
Views:	118
Size:	80.5 KB
ID:	199826  
chaley is offline   Reply With Quote
Old 02-20-2023, 10:17 AM   #10
culytera
Zealot
culytera ought to be getting tired of karma fortunes by now.culytera ought to be getting tired of karma fortunes by now.culytera ought to be getting tired of karma fortunes by now.culytera ought to be getting tired of karma fortunes by now.culytera ought to be getting tired of karma fortunes by now.culytera ought to be getting tired of karma fortunes by now.culytera ought to be getting tired of karma fortunes by now.culytera ought to be getting tired of karma fortunes by now.culytera ought to be getting tired of karma fortunes by now.culytera ought to be getting tired of karma fortunes by now.culytera ought to be getting tired of karma fortunes by now.
 
Posts: 125
Karma: 295674
Join Date: Jul 2021
Device: iPhone
Quote:
Originally Posted by chaley View Post
Is this option checked in Preferences / Behavior?
It wasn't, didn't even notice that was off. That fixed my issues. It doesn't properly sort the ones that started with a number as mentioned on the option, but I don't mind. I can just use the other style anyway for the composite column. Thanks!
Attached Thumbnails
Click image for larger version

Name:	wordcount_fixed.jpg
Views:	106
Size:	93.6 KB
ID:	199829  
culytera is offline   Reply With Quote
Old 02-20-2023, 02:28 PM   #11
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: 10,981
Karma: 75337983
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
I actually looked for a setting like that... but in tweaks. Thanks for clearing up the mystery!
ownedbycats is online now   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Sorting of months in Tag Browser ownedbycats Library Management 2 09-01-2022 03:09 PM
Hierarchical tags and sorting in tag browser ownedbycats Calibre 4 06-08-2020 07:01 PM
Tag Browser - Numerical sorting bonked? Lofwyr23 Calibre 3 06-14-2014 06:28 PM
Tag Browser is not sorting at all RennyM Library Management 5 05-05-2014 07:30 PM
Sorting tag values in tag browser mcam Library Management 15 08-25-2013 05:50 AM


All times are GMT -4. The time now is 05:22 AM.


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