def comp_and_swap(array: list[int], index1: int, index2: int, direction: int) -> None:
    if (direction == 1 and array[index1] > array[index2]) or (
        direction == 0 and array[index1] < array[index2]
    ):
        array[index1], array[index2] = array[index2], array[index1]