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 10-09-2022, 08:43 AM   #1
Katja_hbg
Groupie
Katja_hbg can grok the meaning of the universe.Katja_hbg can grok the meaning of the universe.Katja_hbg can grok the meaning of the universe.Katja_hbg can grok the meaning of the universe.Katja_hbg can grok the meaning of the universe.Katja_hbg can grok the meaning of the universe.Katja_hbg can grok the meaning of the universe.Katja_hbg can grok the meaning of the universe.Katja_hbg can grok the meaning of the universe.Katja_hbg can grok the meaning of the universe.Katja_hbg can grok the meaning of the universe.
 
Posts: 183
Karma: 158116
Join Date: Oct 2015
Device: Kobo Glo HD (landscape), Kobo Aura One
how to sort numeric

Inspired from a thread «how to search for only the first occurency ...», I tried something like «oldes book of an author»... and I made it ... almost.

As «oldest» is referring to my library, I search for that book with the lowest id of an author. I search book by author and sort them by id. But that sorting is alphabetic and therefore 1060 comes before 888.

In a template search I use
...
books_of_author = book_values ('id', searchstring, ',' , 99) ;
list_split (list_sort (books_of_author, 0, ','), ',', 'book_of_author_id');
...

Can someone help, to get the list of ids ordered numeric?
Katja_hbg is offline   Reply With Quote
Old 10-09-2022, 10:51 AM   #2
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
There is no numeric list sort in GPM templates. However, you can get the same effect by formatting the numbers with leading zeros, as in
Code:
program:
	ids = book_values('id', 'series:true', ',', 0);
	new_ids = '';
	for id in ids:
		new_ids = new_ids & format_number(id, '04d') & ','
	rof;
	list_sort(new_ids, 0, ',')
However, I suspect you are sorting to find the minimum. If so then instead of rebuilding and sorting the list you could do
Code:
program:
	ids = book_values('id', 'series:true', ',', 0);
	minimum = 9999999999;
	for id in ids:
		if id <# minimum then
			minimum = id
		fi
	rof;
	minimum
chaley is offline   Reply With Quote
Advert
Old 10-09-2022, 01:07 PM   #3
Katja_hbg
Groupie
Katja_hbg can grok the meaning of the universe.Katja_hbg can grok the meaning of the universe.Katja_hbg can grok the meaning of the universe.Katja_hbg can grok the meaning of the universe.Katja_hbg can grok the meaning of the universe.Katja_hbg can grok the meaning of the universe.Katja_hbg can grok the meaning of the universe.Katja_hbg can grok the meaning of the universe.Katja_hbg can grok the meaning of the universe.Katja_hbg can grok the meaning of the universe.Katja_hbg can grok the meaning of the universe.
 
Posts: 183
Karma: 158116
Join Date: Oct 2015
Device: Kobo Glo HD (landscape), Kobo Aura One
Thanks Chaley,
I take the second suggestion and now all looks good.
Katja_hbg is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Numeric sorting valdearg Library Management 2 10-31-2020 05:26 PM
Sorting on numeric custom columns? rmzg Calibre Companion 8 10-08-2016 04:04 AM
Arithmetic operations on numeric fields pdurrant Calibre 6 12-31-2014 07:51 AM
Non-numeric series indices (for Kobo) GeoffR Devices 4 03-05-2013 09:06 PM
Cybook Numeric Entry Dialog delphidb96 OpenInkpot 8 08-07-2008 09:54 AM


All times are GMT -4. The time now is 04:42 PM.


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