human
I wrote the below code

    def cset_sort(x, y):
        x_global = 0
        if in6_isgladdr(x):
            x_global = 1
        y_global = 0
        if in6_isgladdr(y):
            y_global = 1
        res = (y_global - x_global)
        if ((res != 0) or (y_global != 1)):
            return res
        if (not in6_isaddr6to4(x)):
            return (-1)
        return (- res)
    cset = []
    if (in6_isgladdr(addr) or in6_isuladdr(addr)):
        cset = filter((lambda x: (x[1] == IPV6_ADDR_GLOBAL)), laddr)
    elif in6_islladdr(addr):
        cset = filter((lambda x: (x[1] == IPV6_ADDR_LINKLOCAL)), laddr)
    elif in6_issladdr(addr):
        cset = filter((lambda x: (x[1] == IPV6_ADDR_SITELOCAL)), laddr)
    elif in6_ismaddr(addr):
        if in6_ismnladdr(addr):
            cset = [('::1', 16, loname)]
        elif in6_ismgladdr(addr):
            cset = filter((lambda x: (x[1] == IPV6_ADDR_GLOBAL)), laddr)
        elif in6_ismlladdr(addr):
            cset = filter((lambda x: (x[1] == IPV6_ADDR_LINKLOCAL)), laddr)
        elif in6_ismsladdr(addr):
            cset = filter((lambda x: (x[1] == IPV6_ADDR_SITELOCAL)), laddr)
    elif ((addr == '::') and (plen == 0)):
        cset = filter((lambda x: (x[1] == IPV6_ADDR_GLOBAL)), laddr)
    cset = map((lambda x: x[0]), cset)
    cset.sort(cmp=cset_sort)
    return cset

What's a good function header?
assistant
#Here's a good function header.

def construct_source_candidate_set(addr, plen, laddr, loname):