def comparePlugin(x,y):
    """
    Customized comparison function for sorting based on
    priority and then name in alphabetical order.
    
    Usage: ListOfPluginInstances.sort(comparePlugin)
    """
    
    if x.priority != y.priority:
        return x.priority-y.priority
    
    if x.name > y.name:
        return 1
    elif x.name < y.name:
        return -1
    return 0