def compare_entities(e1, e2):
    """
    Comparison function for entities.

    Compares sorting priority.
    Returns:
        1 if e1 is higher
        0 if e1 and e2 are equal
       -1 if e2 is higher
    """
    sp1 = e1.sorting_priority
    sp2 = e2.sorting_priority
    if sp1 > sp2:
        return 1
    elif sp1 == sp2:
        return 0
    else:
        return -1