How to swap an item in a list while keeping the order intact

I have a list of texts, e.g.

B
A
E
D
C

I want to swap E with F in a workflow, without changing the order of the items.

I can remove E and add F but then F would be added at the end, instead of being inserted at where E was.

Is there a way to do it? Or is a plugin needed? Thanks :slight_smile:

If these items are from the database, you could add a field to the data type that is called sort order and be of type number and use that for sorting the list and so if you want to switch E with F you simply swap their sort order numbers in the DB

If these lists are not from the database, you could look into some plugins that do list manipulations of which I believe there are a few.

1 Like

It’s not from the database. I’ll look into the plugins. Thanks!

Hi @jayy ,

  • Assume that you have a list of text in state called text :
    If you want to replace item and keep order of elements
    β†’ the way to do that by using find and replace you will use find and replace as you see
    [1] β†’ with value you want to replace
    [2] β†’ value you want to add to the list

    PREVIEW WHAT I EXPLAINED :
    tutorial_bubble
1 Like

Oh that’s brilliant. Thank you!

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.