I would do this, assuming that there is only one priority item
Code:
{#genre:'list_contains($, ',', '^bar$', 'bar', sublist(list_sort($, 0, ','), 0, 1, ','))'}
If there can be more than one priority item I would use this as a stored template named list_priority_item
Code:
program:
arguments(lst='No list argument given', items='');
r = '';
for l in items:
if !r then
r = str_in_list(lst, ',', l, l, '')
fi
rof;
if !r then
r = sublist(list_sort(lst, 0, ','), 0, 1, ',')
fi;
r
and call it like this:
Code:
{#genre:'list_priority_item($, 'Completed, Bar')'}
NB 1: calling stored templates from TPM is currently broken running from source. I will submit a fix soon.
NB 2: the loop in the stored template is a bit strange because the template language doesn't have a "break" statement.