Top Level Namespace
Defined Under Namespace
Instance Method Summary collapse
-
#deep_sort(obj, options = {}) ⇒ Object
and if you don’t like calling member methods on objects, these two functions do it for you.
-
#deep_sort!(obj, options = {}) ⇒ Object
similar to the deep_sort method, but performs the deep sort in place.
Instance Method Details
#deep_sort(obj, options = {}) ⇒ Object
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.
107 108 109 110 111 112 113 114 115 |
# File 'lib/deepsort.rb', line 107 def deep_sort(obj, = {}) if obj.respond_to? :deep_sort obj.deep_sort() elsif obj.respond_to? :sort obj.sort else obj end end |
#deep_sort!(obj, options = {}) ⇒ Object
similar to the deep_sort method, but performs the deep sort in place
118 119 120 121 122 123 124 125 126 |
# File 'lib/deepsort.rb', line 118 def deep_sort!(obj, = {}) if obj.respond_to? :deep_sort! obj.deep_sort!() elsif obj.respond_to? :sort! obj.sort! else obj end end |