Sha256: 8960081beb1f323b3ce41a2c949c69123347f586f8b55dad6c7511c058fd1973

Contents?: true

Size: 305 Bytes

Versions: 11

Compression:

Stored size: 305 Bytes

Contents

module Abstractivator
  module Sort
    def deep_sort_hash(obj)
      case obj
      when Hash
        obj.sort.each_with_object({}) do |(k, v), a|
          a[k] = deep_sort_hash(v)
        end
      when Array
        obj.map(&method(:deep_sort_hash))
      else
        obj
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
abstractivator-0.20.0 lib/abstractivator/sort.rb
abstractivator-0.19.0 lib/abstractivator/sort.rb
abstractivator-0.18.0 lib/abstractivator/sort.rb
abstractivator-0.17.0 lib/abstractivator/sort.rb
abstractivator-0.16.0 lib/abstractivator/sort.rb
abstractivator-0.15.0 lib/abstractivator/sort.rb
abstractivator-0.14.0 lib/abstractivator/sort.rb
abstractivator-0.13.0 lib/abstractivator/sort.rb
abstractivator-0.12.0 lib/abstractivator/sort.rb
abstractivator-0.11.0 lib/abstractivator/sort.rb
abstractivator-0.10.0 lib/abstractivator/sort.rb