Module: WestfieldSwagger::Utilities
- Defined in:
- lib/westfield_swagger/utilities.rb
Instance Method Summary collapse
Instance Method Details
#deeply_sort_hash(object) ⇒ Object
taken from stackoverflow.com/a/13368706
3 4 5 6 7 8 9 |
# File 'lib/westfield_swagger/utilities.rb', line 3 def deeply_sort_hash(object) return object unless object.is_a?(Hash) hash = ActiveSupport::OrderedHash.new object.each { |k, v| hash[k] = deeply_sort_hash(v) } sorted = hash.sort { |a, b| a[0].to_s <=> b[0].to_s } hash.class[sorted] end |