def sort_key(model):
    """key function for case-insensitive sort by name and type"""
    iname = model['data']['name'].lower()
    type_key = {
        'directory' : '0',
        'notebook'  : '1',
        'file'      : '2',
    }.get(model['data']['type'], '9')
    return u'%s%s' % (type_key, iname)