View Single Post
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,476
Karma: 8025702
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