Finding the key of the next record in shuffled slice

I posed a question about whether there is an expression that will give you the “key” to the next record in a UX that has been shuffled according to a value in the spreadsheet. @LeventK indicated that JavaScript has an IndexOf function that does that task but that there isn’t a single expression in AppSheet that does the same work. After thinking about the matter, I came up with a solution that combines the following currently available expressions:

Select()
Orderby()
Index()

If you think such a work around might be useful to you, please see that solution I posted to the original thread.

Continuing the discussion from An expression for "next record" in a shuffled slice:

I posted in the “TIPS & TRICKS” category because I thought I’d come up with a good work around. Initial tests gave me the impression that it was working properly. Subsequently, however, I realized that it is very slow – too slow to be useful in my app. My impression is that the app is trying to make the calculation on every record, even records that are not in the slice. I have hundreds of records but usually only deal with about 20 in any given slice, so restricting virtual formula calculations to a slice might make a big difference if it could be done. I’ll continue to look into this in the coming weeks. Someone may offer so good advice on the original thread. Thanks for reading.