List Sorting by key

Hi,

Cant see whats wrong, help!
Why is it not sorting correctly by list.indexof

Seems a bit difficult to understand. Could you explain in a simple manner with expectations?

Hi @_Vijay

At node GetItemAtIndex you can see that I have values of:

13
13
13+13
and so on

I need to seperate every number with a ±sign and sum the value to 26, but when I try to sort list 26 dont get placed at the same index as the original list. How can I maintain structure in List.SortByKey?

You can use python to evaluate the string - use Python from String node with the following line of code
"OUT = [eval(item) for item in IN[0]]";

Here’s an example using Dynamo. If you have subtractions as well python would be the way to go

Hi @Mike.Buttery
Thanks for your example, but the example ends up with the same problem I try to solve
The order after spliting + och Sort by Key dont match the original list.

Any solution?

Perhaps sorting by key is not what you want? Or after the string split use item[0] in a code node which will only take the first number

Hi Mike,

Thanks for your effort, I did another solution that works