def sort_key ( x ) : name , ( r , u ) = x return - len ( u ) + u . count ( '}' ) * 100
how to create a sort key in python
>>> sort_key (( name ( ROUTE URL ))) - 3
def sort_key(x):
    """
    >>> sort_key(('name', ('ROUTE', 'URL')))
    -3
    """
    name, (r, u) = x
    return - len(u) + u.count('}') * 100