def compareLayers(layer1, layer2):
    """
    Helper function to compare two layers. The layer with the lower id is considered to be before
    the other layer. This method is used when setting layers visible.
    """
    if layer1.id < layer2.id:
        return -1
    elif layer1.id == layer2.id:
        return 0
    else:
        return 1
