If I have an index array with all unique sequential values, such as:
index_array = array([0, 4, 2, 5, 6, 1, 3, 7, 8])
with a corresponding value array:
value_array = array([0, 400, 200, 500 600, 100, 300, 700, 800])
is it possible to loop through the index array in sequential order, such that I get
array([0, 100, 200, 300, 400, 500, 600, 700, 800])
I need to loop through the index array in order (i.e. 0, 1, 2, 3, 4...) with the corresponding values (i.e. 0, 100, 200, 300, 400). The reason these values aren't in order is because I'm subdividing edges, which means the new edges are added at the end of the index array (using vstack), rather than inserted into the index array at the appropriate point.
The pseudocode (if I was printing out the values), would be something like this:
for point in sorted(index_array):
print sorted(point(value_array))
producing:
0
100
200
300
How memory sensitive is this (I'm guessing I would need to use numpy.where) Is it just better practice to reorder before looping, or is there a performance cost to looping out of order?
value_array[index_array]?