import z3

from fest.symstructs import SymElement


def lexicographical(
    sort: z3.SortRef, left: SymElement, right: SymElement
) -> tuple[bool, SymElement, SymElement]:
    left_i = int(str(left.node)[len(str(sort)) + 1 :])
    right_i = int(str(right.node)[len(str(sort)) + 1 :])

    if left_i <= right_i:
        return True, left, right
    else:
        return False, right, left
