def oe_process(position, value, l_send, r_send, lr_cv, rr_cv, result_pipe):
    global process_lock

    # we perform n swaps since after n swaps we know we are sorted
    # we *could* stop early if we are sorted already, but it takes as long to
    # find out we are sorted as it does to sort the list with this algorithm
    for i in range(0, 10):
        if (i + position) % 2 == 0 and r_send is not None:
            # send your value to your right neighbor
            process_lock.acquire()
            r_send[1].send(value)
            process_lock.release()

            # receive your right neighbor's value
            process_lock.acquire()
            temp = rr_cv[0].recv()
            process_lock.release()

            # take the lower value since you are on the left
            value = min(value, temp)
        elif (i + position) % 2 != 0 and l_send is not None:
            # send your value to your left neighbor
            process_lock.acquire()
            l_send[1].send(value)
            process_lock.release()

            # receive your left neighbor's value
            process_lock.acquire()
            temp = lr_cv[0].recv()
            process_lock.release()

            # take the higher value since you are on the right
            value = max(value, temp)
    # after all swaps are performed, send the values back to main
    result_pipe[1].send(value)