finding the index of the smallest digit greater than the digit at ' index ' and right to it
i = l - 1 NEW_LINE while i > index : NEW_LINE INDENT if ( num [ i ] > num [ index ] ) : NEW_LINE INDENT if ( greatSmallDgt == - 1 ) : NEW_LINE INDENT greatSmallDgt = i NEW_LINE DEDENT elif ( num [ i ] <= num [ greatSmallDgt ] ) : NEW_LINE INDENT greatSmallDgt = i NEW_LINE DEDENT DEDENT i = i - 1 NEW_LINE DEDENT