If you're wanting a stateless way to shuffle sorry but that's impossible. A shuffle needs state. If you're content with random pairings that are independent of previous pairings then that can be stateless but it's not a shuffle. In that case your function is just an evenly distributed random number from 0 to length-1. If you must have a shuffle, are willing to keep some state, but can't be moving users around in their array I have a solution. Use indirection. You have arrays of users that you don't want to touch. Fine but they're arrays, so you have random access to them. You don't have to move the users. You just have to shuffle an array of indexes into one of them. Say you have two arrays of 10 girls and 10 boys. Just add an array of 10 ints. Lets call it `partner`. `let partner = [0,1,2,3,4,5,6,7,8,9]` `partner.shuffle()` Your 'function' is now `partner[index]`. You could use it like this: `dance(girls[index], boys[partner[index]])`