(child, type_info=None)
return key
Return sortkey based on sort order defined in type_info, or use default
    based on open/closed and opened_on/closed_on dates.
Return sortkey based on sort order defined in type_info, or use default
    based on open/closed and opened_on/closed_on dates.
Return sortkey based on sort order defined in type_info or use default based on open / closed and opened_on / closed_on dates .
def sortkey(child, type_info=None):
    """Return sortkey based on sort order defined in type_info, or use default
    based on open/closed and opened_on/closed_on dates.
    """
    type_info = type_info or {}
    case = child['case']
    if case.closed:
        key = [1]
        try:
            for attr, direction in type_info[case.type]['closed_sortkeys']:
                val = normalize_date(getattr(case, attr))
                if direction.lower() == 'desc':
                    val = get_inverse(val)
                key.append(val)
        except KeyError:
            key.append(datetime.datetime.max - case.closed_on)
    else:
        key = [0]
        try:
            for attr, direction in type_info[case.type]['open_sortkeys']:
                val = normalize_date(getattr(case, attr))
                if direction.lower() == 'desc':
                    val = get_inverse(val)
                key.append(val)
        except KeyError:
            key.append(case.opened_on or datetime.datetime.min)
    return key
def sortkey ( child , type_info = None ) : type_info = type_info or { } case = child [ 'case' ] if case . closed : key = [ 1 ] try : for attr , direction in type_info [ case . type ] [ 'closed_sortkeys' ] : val = normalize_date ( getattr ( case , attr ) ) if direction . lower ( ) == 'desc' : val = get_inverse ( val ) key . append ( val ) except KeyError : key . append ( datetime . datetime . max - case . closed_on ) else : key = [ 0 ] try : for attr , direction in type_info [ case . type ] [ 'open_sortkeys' ] : val = normalize_date ( getattr ( case , attr ) ) if direction . lower ( ) == 'desc' : val = get_inverse ( val ) key . append ( val ) except KeyError : key . append ( case . opened_on or datetime . datetime . min ) return key