# Manipulating adding a list to another list

Hello everybody,

I’d like to add a list to a list which I can control the order of the items. Basically, what I’d like is to add items into a list in the positions I want.

For example, I have 2 lists of points as below
List 1: 1,3,4,6
List 2: 2,5

After adding the list together, the final list would be: 1,2,3,4,5,6

Another example, I have 2 lists as below

List 1: 1,3,4,6,8,9,10,11
List 2: 2,5,7,12

After adding the list together, the final list would be: 1,2,3,4,5,6,7,8,9,10,11,12

Could someone help me with this please?!

Thank you very much in advance!

With the best regards,

Anthony

1 Like

all you have to do is merge the two lists and flatten, then run it through a sort component. which will sort them in numerical order.

Where’s your code/data?

Sort List

Hello Michelchabaneix,

Thank you very much for your reply!

I would do as you said if the lists contain items which is numbers. However as I mentioned, I have a list of Points. I named the points with numbers for the examples easy to understand.

Could you help me with that?!

Best regards,

Anthony

Hello Mr. Oster,

Here is my definition.

Best regards,

Anthony

Asking - Add list into list.gh (5.8 KB)

If its a list of points, and the data structure is the same, then use the entwine component to merge the lists.

Or you could sort the points based on their relative XYZ value, also using the sort component once you merge the lists.

If I had an hour to solve a problem and my life depended on the solution, I would spend the first 55 minutes determining the proper question to ask, for once I know the proper question, I could solve the problem in less than five minutes.

– Albert Einstein

2 Likes

Sorry for the vague definition! Because I guess my definition related to the question I posted initially.

Let me explain again.

I am having:
List1 (contains 4 points) and I names the 4 points 1,3,4,6 respectively .

Lst 2 (contains 2 points) and I names the 2 points 2,5 respectively .

What I would like to do is to add list 1 and list 2 together, so I can have the final list like this: 1,2,3,4,5,6

As I mentioned in the question, what I’d like is to add items into a list in the positions I want.

I hope this is clearer to you, Mr. Oster.

And I hope you could hepl me with this.

Thank you in advance!

Best regards,

Anthony

Asking - Add list into list.gh (5.8 KB)

1 Like

Your model doesn’t match your description of the problem so is useless.

1 Like

Thank you very much for your suggestions! Unfortunately, none of them worked as I wish.

Maybe, my question was vague. If it is so, please take a look of my reply to Mr. Oster.

Best regards,

Anthony

merge_sort_2019Nov19a.gh (14.9 KB)

1 Like

Thank you very much for your solution!

Best regards,

Anthony

Here you go. By the way there is alrdy 1 component that does everything Oster is doing, it is called “sort points” (sort by euclidian coordinates)
In case this is not what you are asking for. I have also created a sort by X then Y.

Enjoy@!
M!

Asking - Add list into list - MC.gh (12.9 KB)

1 Like

No, Sort Points does something very different.
But yeah, there are many ways to sort points and solve “the real (unstated) problem” here. Without assigning “names” (IDs) to the points.

merge_sort_2019Nov19b.gh (13.2 KB)

If you prefer, you can reverse the sorted list.

1 Like

nvm <3 there is a million ways to solve 1 problem - but these will give you different results. It depends on what you are after.! ENJOY

1 Like

Thank you so much for your kind response!

It is now obvious that my question was not clear for you to understand. I would say the solution of Mr. Oster is what I expected. However, I have learn something from your suggestions. I really appreciate that!

Thanks again, Michelchabaneix!

Best regards,

Anthony

This is exactly what I am looking for, Mr. Oster.

Thank you so much for this!

Best regardsm

Anthony

@Joseph_Oster Joseph, your boat design and yacht hull scripts are pretty bad ass, do you share your methodologies anywhere on this forum? I would love to learn some basic level stuff on the hydrostatic analysis and curves surfaces. If not, would you have some recommendations on where I can read about this topic?