Insert Items not behaving as expected?

I am performing a very simple operation, culling indexes form a list, then I need to go back to the original list.

I culled and then inserted the same items… but insert re arranges items in the wrong order. Not sure what the logic is here. If I insert item 0 first and then 3 it seems to work ok… (11.1 KB)

Hi @ShynnSup,

I’ve managed to come up with this quick fix:

I’m not exactly sure what causes the different behaviours, but it might have to do with the internal order in which things are processed inside the Insert component. Passing two index values for a single item might also play a role?

Hi, thanks, but I am afraid that’s not a parametric solution. It does not work when I cull more items for example.

I dont think so. Checked inputting 2 with dup data and same.

In your case, I prefer to use Replace Nulls or Replace Items with Split Tree other than insert items. (13.2 KB)

1 Like

If you remove the items and indices 0 and 3, then your list will be shorter so inserting items at those same indices will end up with a different list. Have a look at this list of six values with their index as a subscript:

\{ A_0, B_1, C_2, D_3, E_4, F_5 \}

Removing the values with the indices 0 and 3 yields:

\{ B_0, C_1, E_2, F_3 \}

and note that each value has a different index now. If you re-insert new values x, y at indices 0 and 3, those values will be inserted at the B and F places, because those are the ones with indices 0 and 3. Yielding:

\{ x_0, B_1, C_2, E_3, y_4, F_5 \}

The component was designed so that the order in which the insertions are specified does not matter, and that you wouldn’t have to take into account how much the indices increment due to earlier insertions. However it does mean you cannot just use the same index-list for removal and insertion, which I admit would be a nice thing to be able to do.


Thank you guys! Makes sense David, everything has pros and cons.