Sha256: 6c554b55976733ea1cb078bd935ade5882c5073e3b85917383c524823e69052e

Contents?: true

Size: 425 Bytes

Versions: 27

Compression:

Stored size: 425 Bytes

Contents

class Hash
  def sort_array!
    keys.each do |key|
      value = self[key]
      self[key] = sort_array0(value)
    end

    self
  end

  private

  def sort_array0(value)
    case value
    when Hash
      new_value = {}

      value.each do |k, v|
        new_value[k] = sort_array0(v)
      end

      new_value
    when Array
      value.map {|v| sort_array0(v) }.sort_by(&:to_s)
    else
      value
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
miam-0.2.5.beta1 lib/miam/ext/hash_ext.rb
miam-0.2.4 lib/miam/ext/hash_ext.rb
miam-0.2.4.beta18 lib/miam/ext/hash_ext.rb
miam-0.2.4.beta17 lib/miam/ext/hash_ext.rb
miam-0.2.4.beta16 lib/miam/ext/hash_ext.rb
miam-0.2.4.beta15 lib/miam/ext/hash_ext.rb
miam-0.2.4.beta14 lib/miam/ext/hash_ext.rb
miam-0.2.4.beta13 lib/miam/ext/hash_ext.rb
miam-0.2.4.beta12 lib/miam/ext/hash_ext.rb
miam-0.2.4.beta11 lib/miam/ext/hash_ext.rb
miam-0.2.4.beta10 lib/miam/ext/hash_ext.rb
miam-0.2.4.beta9 lib/miam/ext/hash_ext.rb
miam-0.2.4.beta8 lib/miam/ext/hash_ext.rb
miam-0.2.4.beta7 lib/miam/ext/hash_ext.rb
miam-0.2.4.beta6 lib/miam/ext/hash_ext.rb
miam-0.2.4.beta5 lib/miam/ext/hash_ext.rb
miam-0.2.4.beta4 lib/miam/ext/hash_ext.rb
miam-0.2.4.beta3 lib/miam/ext/hash_ext.rb
miam-0.2.4.beta2 lib/miam/ext/hash_ext.rb
miam-0.2.4.beta lib/miam/ext/hash_ext.rb