Retain order of items before Merge, to after Merge

I am getting data in a certain order from an HTTP Request. I need to manipulate the data if some items are empty, then re-combine it all again. But it must retain the same order that it started with.

I’ve found “Merge” doesn’t retain the original order of items, as in the below workflow. I’ve managed to keep all the items in the same order in Merge Input 1. If I use “Enrich Input 1,” in the Merge node, it re-arranged things. If I use “Keep Everything,” in the Merge node, it rearranged things. Then I added a “Wait” to Merge Input 2, in case it was just processing those faster and that’s why they ended up first in the Merge output, but that didn’t change anything.

How would I make the final output from Merge be in the same order as they originally came in, and / or the same order they came in from Merge Input 1?

Initial input is:

12345
23456
34567
15793
28933

After merge:

34567
28933
12345
23456
15793

EDIT: I put in sample data to the “On Clicking Execute” but it didn’t pass through to this post. Here is the sample data:

[
{
"twitter_handle":
"@twitter",
"title_url":
"Some Title A",
"post_id":
12345,
"twitter_empty":
"twitter"
},
{
"twitter_handle":
"@twittersupport",
"title_url":
"Some Title X",
"post_id":
23456,
"twitter_empty":
"twittersupport"
},
{
"twitter_handle":
"@",
"title_url":
"Another Title",
"post_id":
34567,
"twitter_empty":
""
},
{
"twitter_handle":
"@twitterhelp",
"title_url":
"Hello World",
"post_id":
15793,
"twitter_empty":
"twitterhelp"
},
{
"twitter_handle":
"@",
"title_url":
"Goodbye World",
"post_id":
28933,
"twitter_empty":
""
}
]

Hi @mmac,
you are right, the merge node at the end really does change the order of items :thinking:

To workaround this issue I added the $itemIndex at the beginning or your workflow (0,1,2,3,etc.) and sort by that index at the end after your merge node.

Here is my example workflow

Thank you, that did the trick!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.