def sort_completions_key(completion):
    """
    sort completions according to their type

    Args:
        completion (jedi.api.classes.Completion): completion

    Returns:
        int: sorting order
    """
    if completion.type == "function":
        return 2
    elif completion.type == "instance":
        return 1
    else:
        return 3