|  06-16-2023, 10:17 AM | #1 | 
| Member  Posts: 13 Karma: 10 Join Date: Sep 2009 Location: Rio de Janeiro, Brasil Device: PRS-600 | 
				
				Ordinal numbers in custom columns (1st, 2nd, 3rd etc)
			 
			
			Hi!  I have the same books in different editions and it's useful to keep them to check the differences. I tried to add a custom column to account for this (Edition) but in the "column type" I chose interger, which does not allow me use add numbers in ordinal format (1st, 2nd, 3rd etc). I thought about using a "text" column type, but I wonder if this would end up limiting my ability to sort books by edition. Is there a better way to do this? Thank you! | 
|   |   | 
|  06-16-2023, 11:58 AM | #2 | 
| Custom User Title            Posts: 11,347 Karma: 79528341 Join Date: Oct 2018 Location: Canada Device: Kobo Libra H2O, formerly Aura HD | 
			
			Text is one option. You may also be able to use a composite column that checks the integer and convert it to text. But that's a bit more of an effort. | 
|   |   | 
|  06-16-2023, 12:51 PM | #3 | 
| Well trained by Cats            Posts: 31,249 Karma: 61360164 Join Date: Aug 2009 Location: The Central Coast of California Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A | 
			
			If the columns purpose is Edition, why Ordinal? 2 in the edition column is the second edition Also note you need to pad text if the number is above 9 if you want to sort (alpha sort rule) Personally, I just append (2nd ed) to the title Stuff in the paren does not affect the sort value | 
|   |   | 
|  06-16-2023, 01:08 PM | #4 | ||
| Member  Posts: 13 Karma: 10 Join Date: Sep 2009 Location: Rio de Janeiro, Brasil Device: PRS-600 | Quote: 
 Quote: 
 | ||
|   |   | 
|  06-16-2023, 01:55 PM | #5 | 
| Custom User Title            Posts: 11,347 Karma: 79528341 Join Date: Oct 2018 Location: Canada Device: Kobo Libra H2O, formerly Aura HD | 
			
			Note that you can use a comments/long-text type column set to 'title'.  Depending on your use, this may be more suitable as It won't appear as a category in the tag browser or be a clickable link in book details. I use it for subtitles. | 
|   |   | 
|  06-16-2023, 03:09 PM | #6 | |
| Grand Sorcerer            Posts: 12,525 Karma: 8065948 Join Date: Jan 2010 Location: Notts, England Device: Kobo Libra 2 | Quote: 
 General Program Mode: Code: program:
	n = raw_field('#myint', '');
	if n then
		t = mod(n, 100);
		if t >=# 4 && t <=# 20 then
			suffix = 'th'
		else
			dex = mod(t, 10);
			if dex >=# 4 then dex = 4 fi;
			suffix = list_item('th,st,nd,rd,th', dex, ',')
		fi;
		return n & suffix
	fi;
	return ''Code: python:
def evaluate(book, context):
	n = book.get('#myint')	
	if n is None:
		return ''
	if 4 <= (n % 100) <= 20:
		suffix = 'th'
	else:
		suffix = ['th', 'st', 'nd', 'rd', 'th'][min(n % 10, 4)]
	return str(n) + suffixBut it does affect searching. | |
|   |   | 
|  | 
| 
 | 
|  Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post | 
| Oxford dictionary 2nd or 3rd edition on 11th gen Kindles? | ksks | Amazon Kindle | 17 | 10-06-2025 08:38 PM | 
| Ratings Custom Columns Created From other Columns | Tanjamuse | Library Management | 4 | 09-28-2020 12:57 AM | 
| Help Needed for Custom Columns Created From other Columns | Tanjamuse | Library Management | 5 | 09-02-2018 06:19 PM | 
| Need help in Custom Columns, template syntax, and rounding numbers | dennocoil | Calibre | 0 | 07-10-2017 03:24 PM | 
| K1 Owners: Have you bought a 2nd (or 3rd...) ereader & if so, what? | texasnightowl | Amazon Kindle | 14 | 07-28-2010 08:34 PM |