![]() |
#1 |
Groupie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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? |
![]() |
![]() |
![]() |
#2 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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, ',') Code:
program: ids = book_values('id', 'series:true', ',', 0); minimum = 9999999999; for id in ids: if id <# minimum then minimum = id fi rof; minimum |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Groupie
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 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. |
![]() |
![]() |
![]() |
|
![]() |
||||
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 |