View Single Post
Old 09-26-2011, 10:55 AM   #13
chaley
Wizard
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: 3,853
Karma: 285886
Join Date: Jan 2010
Location: France
Device: Sony PRS-300, HTC WM6.5, Samsung Galaxy Nexus, HTC Sensation
Quote:
Originally Posted by arspr View Post
I've used a slight variant to your code:
Code:
{#original:'strcmp(list_sort(field('#original_language'),0,','),list_sort(language_strings(field('languages'),0),0,','), 'No', 'Yes', 'No')'}
I suppose that if I sorted before calling language_strings, I would get "Spanish, Latin" because of "esp, lat", which wouldn't match the alphabetically sorted "Latin, Spanish".
You are correct. The code I supplied would not work for that reason.

Why do you start with "{#original:"? That field is never used in the functions (the token $ does not appear). You could use "{:" and make it clear that there is no field being passed into the functions.

I am considering adding a "list_equal" function, where two lists are considered equal if they contain the same items in any order (case insensitive compares). That would get rid of the list_sorts, which are superfluous in this case. One question: I would assume that both lists have the same separator, making the call something like
Code:
list_equal(list1, list2, ',', yes_value, no_value).
What do you think?
__________________
Support calibre developers at no cost to you by using calibre's get books feature.
Use Calibre Companion to wirelessly connect your Android phone or tablet to calibre
charles.haleys.org/calibre
chaley is offline   Reply With Quote