Hi everybody,
I have a problem moving an item from a sublist to another. I saw in another topic that a procedure can be remove the item from the old position and insert it again in the new one. But I don’t know what I have to write in the code block to get the index I want to move.
For example I would like to move the item “b” from sublist 1 into sublist 0 at the index 1.
![](//cdck-file-uploads-us1.s3.dualstack.us-west-2.amazonaws.com/flex022/uploads/dynamobim/original/2X/6/63ab23d481ea44b58bb41c5465d0470ec6560b5a.png)
Thanks in advance for help.
Hi Salvatore,
thanks for your post, your code is very interesting, but it’s not exactly what I’m trying to do.
I would like to delete the item “b” from sublist 1 and add it in sublist 0 at position 1 for example, the resulting list should be this one:
![](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/2X/7/73fa2d07ee953b1ef2d554cad43af948045561ea.png)
I tried to apply the remove and insert nodes, but I don’t know what to write in the code block to get directly the index (or the indices) I want to remove:
I was only able to do this:
but I have to move a lot of items so this procedure is too long, and I think not efficient.
@rosarixx Try this one ![:wink: :wink:](https://emoji.discourse-cdn.com/twitter/wink.png?v=9)
def replace(lsta:var
…
)
{
lstb=List.AddItemToEnd(lsta[1], lsta);
lstb[0]=List.AddItemToFront(lstb[2][1],lstb[0]);
lstb[0]=Reorder(lstb[0],{1, 0, 2, 3});
lstb[1]=List.RemoveItemAtIndex(lstb[1],1);
return={lstb[0],lstb[1]};
};
replace(lsta);
1 Like
Another way, should be fast:
1 Like
Well thanks guys, you give me very interesting material to study.