Assuming this is supposed to be a knuth-fisher-yates shuffle, I think thsi should be

```ruby
# Not sure about this, we need 0 <= j <= idx
j = rand(idx)
a[j], a[idx] = a[idx], a[j]
```