Q:

Python find indices in an array based on conditions

I have a list/array(can make them arrays, doesn't matter):
array = [1,2,1,1,2,3,1,2,1,2,3,1,2,3,4,5]

I would like to create a new_array FROM array which looks like this:
new_array = [[1,2],[1],[1,2,3],[1,2],[1,2,3],[1,2,3,4,5]]

The logic I came up with was to start with a=0,b=1 and loop through array, when the value of array[a] < array[b], then a+=1,b+=1, but if the value of array[a]>=array[b], then append the value of b:
Here is what I tried:
index_1 = [] # This will be the list which will have the FIRST index 
index_2 = [] # This will be the list which will have the SECOND index
a = 0
b = 1
for i in array:
    if i[a] < i[b]:
        a = a+1
        b = b+1
    elif i[a] >= i[b]:
        index_2.append(b)
        index_1.append(a)

So index_1 will have the first index and index_2 will have the second index and then, we can create the new_array by:
new_array = [(array[start:end]) for start,end in zip(index_1,index_2)]

Unfortunately, even though my idea is correct, the loop stops in if i[a]<i[b] because of IndexError: invalid index to scalar variable.. 

A:

We can go through the array directly by the elements (more precisely by a pair of neighboring elements) simultaneously forming the result.     
We initialize our result with a sublist of the 1st element of the array and then: 

 if the next element is greater than the previous one, we add it to the last sublist
 otherwise -  we add a new sublist with this element to the result.
array = [1,2,1,1,2,3,1,2,1,2,3,1,2,3,4,5]

new_array = [[array[0]]] # assume the array is not empty
for a,b in zip(array, array[1:]):
    if a<b:
        new_array[-1].append(b)
    else:
        new_array.append([b])

print(new_array)
# [[1, 2], [1], [1, 2, 3], [1, 2], [1, 2, 3], [1, 2, 3, 4, 5]]

UPD.
Alternatively, we can implement it with indices.
(based on this answer by @fortran)  
First, prepare indices to split the array:
idxs_to_split = [idx for idx in range(1, len(array)) if not array[idx-1] < array[idx]]
pairs = zip([0] + idxs_to_split, idxs_to_split + [None])

Second, implement the splitting itself:
new_array = [array[i:j] for i,j in pairs]

print(new_array)
# [[1, 2], [1], [1, 2, 3], [1, 2], [1, 2, 3], [1, 2, 3, 4, 5]]

