Hello Makers, I got a list of fruits in a Google Sheets :
Apple
Banana
Orange
Mango
Strawberry
Blueberry
Pineapple
Watermelon
If I got one of them as an input, how to put it at the top of the list?
For example, I got Strawberry from a Webhook trigger, then I use the “Get range Values” Google Sheets module. Finally, I want to reorder the list and display it in an email for example, like this :
We’ll use getRange from sheets and aggregate all fruits in one big text separated with a comma, but ignore the topFruit (strawberry). We’ll then split this list back to a list (filtered array), and add strawberry as first element of the list. I use here merge() with one-element array of Strawberry and filtered array without strawberry.
Edit : found an improvement - the last step of integrating topfruit into the array can be done in text aggregator module itself. we add if(bundleposition=1;topfruit,;emptystring). This will effectively add topfruit on top of the first element.
Splitting this back with , separator would get you a proper array of elements. The empty element shouldn’t be a problem and can be removed from the array.
Hi @XenoMax, The problem is that the range from Sheets would be a list of bundles and the only method I’ve found to convert it to an array is text aggregator - and then split it.