I have a collection of elements that I want to shuffle randomly, but every element has a different priority or weight. So the element with bigger weight has to have more pro
def self.random_suffle_with_weight(elements, &proc)
consecutive_chain = []
elements.each do |element|
proc.call(element).times { consecutive_chain << element }
end
consecutive_chain.shuffle.uniq
end