Issues with random sorting and API workflow

I am using an API workflow on a list, to create a bunch of things. Each thing has an index number (from 1 to n) and a user. The users need to be sorted randomly, so that each user gets a random index number (but all index numbers are accounted for). I have attacked this problem from multiple different angles and I keep running into different issues. Here is a previous post related to the same issue:

At first, I tried to sort the users randomly using a custom state, and pass the list of randomly sorted users as the list to run on. Then, I would index the count by 1 for each iteration of the API workflow. Unfortunately, API workflows aren’t meant for looping, and I was experiencing extreme delays because I had to delay each run of the workflow by 5 to 10 seconds in order for the indexing to work properly. And what happens if there are server issues? Then, I tried @stvnsnthn’s suggestion. But again, this relies on clever timing to simulate a loop.

Eventually it dawned on me that instead of passing the randomly sorted list of users to the workflow, I could just pass the index list to the workflow. Then I can pass a randomly sorted list of users as a parameter, and pull the appropriate user for each index. (I tried just passing the user # “This number” to the workflow instead of the entire list, but for some reason it won’t let me.) For example, I run the list on 1, 2, 3, 4, 5. Each workflow is passed this list of 5 randomly sorted users which was created previously as a custom state on the page. When thing #1 is created, it should pull random user 1 from the list. When thing #2 is created, it should pull random user 2. So on and so forth until all the things are created. This escapes any timing requirement. Unfortunately, my results are all over the place. It always creates the right number of things. Sometimes all 5 users are there, but many times some users are repeated and some are left out.

I can think of 2 ways this could happen:

  1. The random list doesn’t actually contain each thing in a random order–instead, it contains a randomly selected user 5 times (so some may be repeated, and some left out).
  2. The random list is fine, but somehow gets re-sorted for each iteration of the workflow.

Does anybody have experience with this, and could help me understand why this is happening? I have dug into the debugger but it is impossible to see what is going on inside the API workflow.