Manipulate list of lists

Hi i have a list of lists with pairs of 2 values. Index 0 in each list is the ID and index 1 is the value. I want to create a new list of lists where every value with similar ID gets summed and put under the same ID.

I have created a panel manually to show what i want to obtain. To the left is my list, and to the right is the one i created manually.

3. Attach minimal versions of all the relevant files


Manipulate list of lists_re.gh (9.1 KB)

2 Likes

Thanks. What is the gray box (output from +1 “list items”) ? I have tried to use the same canvas as you without the gray box, but i got an issue where not all the numbers are added.

Totally off topic, but how do you get your canvas displayed like that? looks much cleaner with the name of the function above instead of inside the box

You mean Relay(Params–>Util–>Relay)?
What version of rhino are you using? It’s been a standard object since R6.
Just try to double-click the wire.

Display → check “Display Icons”

1 Like

Im using Rhino 7. I have only been using it for a month so I am not familiar with all the functions yet. i found my mistake. i used mass multiplication instead of addition. Thank yuo so much for your sollution! it was extreamly helpfull. Now i have gotten a better understanding of the functions of grasshopper already

I am able to get the icons displayed as you have, however i also want the function name listed above just like you. i dont sem to have that option.

1 Like

I know. However when i activate that button my canvas looks like this. I still want to be able to see the name of the function like you do above the box. I am not experienced enough with the symbols to understand them without the name of the function.(i have already started to use the relay function as you can see, so thanks for that :smiley: )
image

you could try the Bifocals or Parachute plugins from food4rhino
I tried them a while ago, perhaps there is a better one now?

SUNGLASSES

1 Like

Follow up question:
Is there a simple way to sort the list based on the numbers at index 0?

Like this?


Manipulate list of lists_re.gh (11.9 KB)

1 Like

Amazing! thank you so much. i am new to grasshopper, so could you try to make a short explanation of what is happening here?

From right to left:
The Replace Paths will “reshuffle” a tree. You need to provide paths to move from, and paths to move to.
So, those 2 lists of paths will tell the component where to move your data. The path in Item 0 in one list will go to the path in Item 0 of the other list (blue in the image).

The Sort List component will sort whatever list you give it in A (B, C, etc can be added by zooming in Grasshopper) while sorting the numbers you provide in K.
The Tree Statistics gives you a list of the Tree Paths.