Sha256: 9ad62c985a74e0b9ace1e421cb079e00ed516193182211ea394fd5b4ada4e510
Contents?: true
Size: 337 Bytes
Versions: 1
Compression:
Stored size: 337 Bytes
Contents
class Hash def sort_by_key(&block) self.keys.sort(&block).reduce({}) do |seed, key| seed[key] = self[key] if seed[key].is_a?(Hash) seed[key] = seed[key].sort_by_key(&block) elsif seed[key].is_a?(Array) seed[key] = seed[key].map { |i| i.sort_by_key(&block) } end seed end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
doggy-3.0.0.pre.beta1 | lib/doggy/hash_sort.rb |