def actioncmp(ap1, ap2):
    '''Compare two actions for sorting purposes.  Return negative,
    zero, or positive if the first action is less than, equal to, or
    greater than the first.
    '''
    rc = ap1.sp.index - ap2.sp.index
    if rc == 0:
        rc = ap1.type - ap2.type
    if rc == 0 and ap1.type == REDUCE:
        rc = ap1.x.rp.index - ap2.x.rp.index
    assert rc != 0 or ap1 == ap2
    return rc
dataset/ETHPy150Open probcomp/bayeslite/external/lemonade/dist/lemonade/action.py/actioncmp/original