Reorder the list according to a new list of indices

Hi,

I would like to ask if you could give me a tip on how to solve a logic problem with the list reordering.

I have my list A, which contains lines in the correct order following the clockwise direction. I have list B with the same curves as in list A, but the order is mixed up.

I would like to reorder list B according to the length values in list A.

The reordering procedure is easy, but I am struggling with the problem that two curves in list A have the same length value (at index 2 and 4). When I am defining the list of indices by combining lists A and B using the List.IndexOf node, the node sees that the length in list A is the same and reports “2” for the index 1 and 3 of the list, instead of “2" in index 1 and “4” in index 3.

In the end, I have a list with correct lengths but the curve at indices 1 and 3 are the same which creates geometry problem.

Do you know how I could solve it automatically, without digiting the correct order manually?

Maybe I should use another key to reorder the list?

Many thanks for your help!

Hi @Julia_Ratajczak ,

Have you tried using the nodes List.IndexOf and List.GetItemAtIndex?

1 Like

Hi,
my initial curves can change if I will move the slider. It means that in some conditions the list can have or does not have curves with the same values. In case it would have, I would like to get always a correct order. For this reason, maybe the length is not the best key to reorder it, but I do not have a better idea for now.

Best regards,
Julia

I am not following what you are trying to achieve exactly here.

You have two lists containing the exact same curves and you want to order list B according to list A, wouldn’t that simply result in list A?

Hi!
Now I have figured out how to use the List.GetItemaAtIndex:)
Thanks!

1 Like