From: "Iñaki Baz Castillo" Date: 2011-06-23T07:11:15+09:00 Subject: Re: How to order a hash based on its keys? 2011/6/22 Robert Klemme : > Aha!  This is how I'd probably do it. > https://gist.github.com/1040631 It's really cool :) I've done it using a different approach, but I think the main algorithm is similar: pick = rand(@total) @items.each_with_index do |it, idx| sum += @weight[it] return idx if sum > pick end I do something similar: https://gist.github.com/1041339 Note that my code does not use real SRV records for now, but similar objects (hash/arrays in fact) and I provide it in a specific format (a hash with SRV priorities as keys). I'm mostly interested in efficience and I'm satisfied with the results of my code. Thanks a lot. -- Iñaki Baz Castillo