I have a 1D boolean array a, for example
a = numpy.array([0, 1, 0, 0, 1, 1, 1, 0, 1], dtype='bool')
I want to use numpy.where to find the indices of the True elements
idx = numpy.where(a)[0]
Can I assume that the output idx is always sorted in an ascending order? Does numpy.where guarantee that? I am asking this question because the document does not say anything about it and the numpy.where is written in C, which is not obvious to tell how it works.