Minimum in Rotated Sorted Array - Binary Search / Implicitly Sorted Array

the result is incorrect for this array: [3,1,2]

So, I am not satisfied a bit with the solution and also with the problem description.
It states that the array is “sorted” but does not specifies if it is ascending or descending - it assumes that it is ascending.

But if you need a solution for both variants, here you go:

def find_min_rotated(arr: List[int]) -> int:
    l, m, r = 0, 0, len(arr) - 1
    while l <= r:
        m = (l + r) // 2
        left, mid, right = arr[l], arr[m], arr[r]
        
        if left > right > mid:  # asc rotated portion
            r = m
        elif right > left > mid:  # dsc rotated portion
            l = m
        elif left <= right:  # asc portion
            if left <= mid:  r = m - 1
            else:            l = m + 1
        elif left >= right:  # dsc portion
            if mid >= right: l = m + 1
            else:            r = m - 1
    
    return m

p.s. - passes all the test cases and also works for reversed array