Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/ext/hash.rb

Instance Method Summary collapse

Instance Method Details

#to_ordered_hashObject



2
3
4
5
6
7
8
9
# File 'lib/ext/hash.rb', line 2

def to_ordered_hash
  ActiveSupport::OrderedHash.new.tap do |hash|
    self.sort_by{|k,v| k.to_s}.each do |k, v|
      v = v.sort_by { |e| e.to_s } if v.is_a? Array
      hash[k] = v
    end
  end
end