class Object

Public Instance Methods

deep_sort(obj, options = {}) click to toggle source

and if you don't like calling member methods on objects, these two functions do it for you. if the object cannot be deep sorted, it will simply return the sorted object or the object itself if sorting isn't available.

# File lib/deepsort.rb, line 107
def deep_sort(obj, options = {})
  if obj.respond_to? :deep_sort
    obj.deep_sort(options)
  elsif obj.respond_to? :sort
    obj.sort
  else
    obj
  end
end
deep_sort!(obj, options = {}) click to toggle source

similar to the deep_sort method, but performs the deep sort in place

# File lib/deepsort.rb, line 118
def deep_sort!(obj, options = {})
  if obj.respond_to? :deep_sort!
    obj.deep_sort!(options)
  elsif obj.respond_to? :sort!
    obj.sort!
  else
    obj
  end
end