<garvit244>1053_1.py
def prevPermOpt1( A):
    left, right = len(A)-2, len(A)-1
    for left in range(len(A)-2, -1, -1):
        if A[left] > A[left+1]:
            break
    else:
        return A
    right = A.index(max(ele for ele in A[left+1:] if ele < A[left]), left)
    A[left], A[right] = A[right], A[left]
    return A
def sample_funcname ( var_0 ) :
    var_3 , var_5 = len ( var_0 ) - 2 , len ( var_0 ) - 1
    for var_3 in range ( len ( var_0 ) - 2 , - 1 , - 1 ) :
        if var_0 [ var_3 ] > var_0 [ var_3 + 1 ] :
            break
    else :
        return var_0
    var_5 = var_0.index ( max ( var_9 for var_9 in var_0 [ var_3 + 1 : ] if var_9 < var_0 [ var_3 ] ) , var_3 )
    var_0 [ var_3 ] , var_0 [ var_5 ] = var_0 [ var_5 ] , var_0 [ var_3 ]
    return var_0
