I Need A Creative Way To Sort a List

Hi Guys! I’m in need of help thinking of a creative way to sort a list. Here’s the scenario:

Step 1: I’m using OpenAI to generate an outline
Step 2: I’m using bubble to separate the output from OpenAI based on each new line.
Step 3: I am then taking that list and saving it as a state in the page
Step 4: I’m scheduling an API workflow that creates a new item in my database for each item of the list that is saved to the state.

This works but the list in my database is out of order when I display it in a repeating group, even if I sort by created date. I need some way to be able to add an index or sort number to the items being created in the API workflow. However, I can’t seem to find a way to do that as I think the list is getting out of order when it’s being saved to the state.

Any ideas?

Is there a reason you are saving each line as a state and not sending the entire outline to the db to parse out on the back-end?

If you must use states to store the outline, you can insert the index/line number into the state and then extract it in the API workflow to determine the order of the that item.