How to return the value and the weight of sampled element?

Less memory intensive version could be

idx = sample(Weights(weights))
(values[idx], weights[idx])
3 Likes