def insert_ordered ( value , array ) : index = 0 # search for the last array item that value is larger than for n in range ( 0 , len ( array ) ) : if value >= array [ n ] : index = n + 1 array . insert ( index , value ) return index
python progarm to insert an element in sorted array
This will insert the value into the array keeping it sorted and returning the index where it was inserted
def insert_ordered(value, array):
    """
    This will insert the value into the array, keeping it sorted, and returning the
    index where it was inserted
    """

    index = 0

    # search for the last array item that value is larger than
    for n in range(0,len(array)):
        if value >= array[n]: index = n+1

    array.insert(index, value)
    return index