View Single Post
Old 01-28-2018, 02:40 AM   #3
ilovejedd
hopeless n00b
ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.ilovejedd ought to be getting tired of karma fortunes by now.
 
ilovejedd's Avatar
 
Posts: 5,110
Karma: 19597086
Join Date: Jan 2009
Location: in the middle of nowhere
Device: PW4, PW3, Libra H2O, iPad 10.5, iPad 11, iPad 12.9
Sorry, I didn't explain better. I'm trying to create a custom function that would do a list_sort on lists inside a list.

The code below just gives me:

S/R TEMPLATE ERROR global name 'list_sort' is not defined

Code:
def evaluate(self, formatter, kwargs, mi, locals, val, start_index, end_index, sep):
    if not val:
        return ''
    si = int(start_index)
    ei = int(end_index)
    # allow empty list items so counts are what the user expects
    val = [v.strip() for v in val.split(sep)]
    # sort John/Jane to Jane/John
    for i, v in enumerate(val):
        val[i] = list_sort(v,0,'/')
    if sep == ',':
        sep = ', '
    try:
        if ei == 0:
            return sep.join(val[si:])
        else:
            return sep.join(val[si:ei])
    except:
        return ''

Last edited by ilovejedd; 01-28-2018 at 02:48 AM.
ilovejedd is offline   Reply With Quote