module WestfieldSwagger::Utilities
Public Instance Methods
deeply_sort_hash(object)
click to toggle source
taken from stackoverflow.com/a/13368706
# 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