From: "Iñaki Baz Castillo" Date: 2011-06-23T00:07:56+09:00 Subject: Re: How to order a hash based on its keys? 2011/6/22 Piotr Szotkowski : > srvs.sort { |a, b| (a.priority <=> b.priority).nonzero? or (b.weight <=> a.weight).nonzero? or rand } The problem is that a SRV record with priority 1 and weight 20 must not be *always* preferred over another record with priority 1 and weight 10 (the first record must be chosen ~2 times as its weight is double high). Anyhow I've already coded a method for such weight algorithm ;) Thanks. -- Iñaki Baz Castillo