Sha256: a27e79f20f1cd7bad69cacd7b25007e4242bc8e190ab16943754eddc36e850ce

Contents?: true

Size: 310 Bytes

Versions: 1

Compression:

Stored size: 310 Bytes

Contents

module Abstractivator
  module Sort
    def deep_sort_hash(obj)
      case obj
      when Hash
        obj.sort.to_h.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

1 entries across 1 versions & 1 rubygems

Version Path
abstractivator-0.8.0 lib/abstractivator/sort.rb