# Have "merge" component output list order according to input order

**URL:** <https://discourse.mcneel.com/t/have-merge-component-output-list-order-according-to-input-order/61761>\
**Category:** Grasshopper2\
**Created:** [April 30, 2018, 3:16pm UTC](https://discourse.mcneel.com/t/have-merge-component-output-list-order-according-to-input-order/61761 "2018-04-30T15:16:39Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Peugeot](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/peugeot/32/342410_2.png) [@Peugeot](https://discourse.mcneel.com/u/Peugeot)\
**Post date:** [April 30, 2018, 3:16pm UTC](https://discourse.mcneel.com/t/have-merge-component-output-list-order-according-to-input-order/61761/1 "2018-04-30T15:16:40Z")

</div>

This post suggests a minor evolution of the “merge” component.

The “as-is” situation is that output order is not following the input order. There are cases ([Does the "tangent curve" component confuses input order?](https://discourse.mcneel.com/t/does-the-tangent-curve-component-confuses-input-order/60913)) when it might prove confusing.

Suggestion : the output order of the “merge” component should not be a runtime decision by GH, but rather a compile time decision from the specification, hence the input order.

---

<div class="post-metadata">

**Author:** ![RIL](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/ril/32/771758_2.png) [@RIL](https://discourse.mcneel.com/u/RIL)\
**Post date:** [April 30, 2018, 4:53pm UTC](https://discourse.mcneel.com/t/have-merge-component-output-list-order-according-to-input-order/61761/2 "2018-04-30T16:53:58Z")

</div>

> [@Peugeot](#):
>
> input order.

Seconded.

// Rolf

---

<div class="post-metadata">

**Author:** ![qythium](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/qythium/32/84125_2.png) [@qythium](https://discourse.mcneel.com/u/qythium)\
**Post date:** [April 30, 2018, 5:14pm UTC](https://discourse.mcneel.com/t/have-merge-component-output-list-order-according-to-input-order/61761/3 "2018-04-30T17:14:57Z")

</div>

I opened the gh file from your original post, and it looks like the ‘bug’ was actually expected behaviour due to your D1 / D2 inputs being on different branches:

![image](https://global.discourse-cdn.com/mcneel/original/3X/2/1/2188c10726fe63e26381652c595c6fcd80815837.jpg)  
and if you unflatten the output this is what you see:  
The two lists were never merged in the first place- flattening the output obscured that fact and made things confusing by respecting the branch indexing order.  
 ![image](https://global.discourse-cdn.com/mcneel/original/3X/e/9/e99f3d6c9dc24ce89eceafee4de83e37a781bb2b.jpg)

In your case, all you have to do is flatten the _inputs_ to get things in the desired order:

 ![image](https://global.discourse-cdn.com/mcneel/original/3X/f/6/f6da3cd2ee89341983716ca4cdf5e23603e95c9b.png)

---

<div class="post-metadata">

**Author:** ![Peugeot](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/peugeot/32/342410_2.png) [@Peugeot](https://discourse.mcneel.com/u/Peugeot)\
**Post date:** [May 1, 2018, 11:48am UTC](https://discourse.mcneel.com/t/have-merge-component-output-list-order-according-to-input-order/61761/4 "2018-05-01T11:48:47Z")

</div>

> [@qythium](#):
>
> The two lists were never merged in the first place- flattening the output obscured that fact and made things confusing by respecting the branch indexing order.

Thank you qythium. Sorry, I’m still on the learning curve with trees. Next time, I will think about output elements in a panel.

---

<div class="post-metadata">

**Author:** ![Xavier\_Ayme](https://avatars.discourse-cdn.com/v4/letter/x/a9a28c/32.png) [@Xavier\_Ayme](https://discourse.mcneel.com/u/Xavier_Ayme)\
**Post date:** [May 1, 2018, 5:46pm UTC](https://discourse.mcneel.com/t/have-merge-component-output-list-order-according-to-input-order/61761/5 "2018-05-01T17:46:40Z")

</div>

@Peugeot Actually this is a common mistake, when tree branches are reduced to a single item, or a single list, it is not obvious to figure out which one is going where after the merge.

If you’re interested, I’ve developped a small component which takes a variable number of lists and output them back to back in a single list, in order. It’s definately not rocket science but if you need it, I can share it with you.

–Xavier

---

<div class="post-metadata">

**Author:** ![Peugeot](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/peugeot/32/342410_2.png) [@Peugeot](https://discourse.mcneel.com/u/Peugeot)\
**Post date:** [May 2, 2018, 11:30am UTC](https://discourse.mcneel.com/t/have-merge-component-output-list-order-according-to-input-order/61761/6 "2018-05-02T11:30:35Z")

</div>

Thks @Xavier_Ayme. I would be interested.

---

<div class="post-metadata">

**Author:** ![yafim](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/yafim/32/472836_2.png) [@yafim](https://discourse.mcneel.com/u/yafim)\
**Post date:** [January 2, 2019, 3:57pm UTC](https://discourse.mcneel.com/t/have-merge-component-output-list-order-according-to-input-order/61761/7 "2019-01-02T15:57:42Z")

</div>

Hi,  
I would be also interested in that component @Xavier_Ayme.

I have a situation where there are 5 lists of 30 points each, corresponding to 5 divided curves, and I want to merge them with a 6th curve in which I’ve ‘shifted’ the indexes of the points.

For now the result is a list with 6 items, but the itex index 0 has 60 points, not 30.

Any ideas?

---

<div class="post-metadata">

**Author:** ![Xavier\_Ayme](https://avatars.discourse-cdn.com/v4/letter/x/a9a28c/32.png) [@Xavier\_Ayme](https://discourse.mcneel.com/u/Xavier_Ayme)\
**Post date:** [January 2, 2019, 5:18pm UTC](https://discourse.mcneel.com/t/have-merge-component-output-list-order-according-to-input-order/61761/8 "2019-01-02T17:18:56Z")

</div>

Hello @yafim, can you please share a small scale definition of what you are trying to do? I don’t quite understand but I am sure a small script could solve it.

---

<div class="post-metadata">

**Author:** ![yafim](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/yafim/32/472836_2.png) [@yafim](https://discourse.mcneel.com/u/yafim)\
**Post date:** [January 3, 2019, 7:01am UTC](https://discourse.mcneel.com/t/have-merge-component-output-list-order-according-to-input-order/61761/9 "2019-01-03T07:01:24Z")

</div>

Thanks @Xavier_Ayme, attached is the script. I’m sure it’s a simple solution I’m just missing something probably.  
Would be great if you can help.

[02.01.19\_Isocurves\_on\_surface.gh](https://global.discourse-cdn.com/mcneel/uploads/default/original/3X/0/f/0f9ae5f3d0297b46014eed387e24c4e43586e9f7.gh) (10.8 KB)

---

<div class="post-metadata">

**Author:** ![Xavier\_Ayme](https://avatars.discourse-cdn.com/v4/letter/x/a9a28c/32.png) [@Xavier\_Ayme](https://discourse.mcneel.com/u/Xavier_Ayme)\
**Post date:** [January 3, 2019, 8:22am UTC](https://discourse.mcneel.com/t/have-merge-component-output-list-order-according-to-input-order/61761/10 "2019-01-03T08:22:12Z")

</div>

Here you are : [02.01.19\_Isocurves\_on\_surface\_Xavier.gh](https://global.discourse-cdn.com/mcneel/uploads/default/original/3X/9/e/9e3df46b6966bbb3afad588c9c0feb1765e4f457.gh) (16.8 KB)

Actually a Path Mapper did the trick. Since the list you were trying to appen was at index 0, I just incremented all other indices of the tree by 1, leaving the 0 index free for the new list.

Cheers
