deep_sort
Sort Array/Hash/Enumerable recursively.
Installation
Add this line to your application's Gemfile:
gem 'deep_sort'
And then execute:
$ bundle
Or install it yourself as:
$ gem install deep_sort
Methods
DeepSort.deep_sort(obj, options = {})
require 'deep_sort/extend'
Array#deep_sort(options = {})
Array#deep_sort!(options = {})
Hash#deep_sort(options = {})
Hash#deep_sort!(options = {})
Enumerable#deep_sort()
Usage
require 'deep_sort'
require 'pp'
require 'set'
hash = {"firstName"=>"John",
"lastName"=>"Smith",
"age"=>25,
"address"=>
{"streetAddress"=>"21 2nd Street",
"city"=>"New York",
"state"=>"NY",
"postalCode"=>"10021"},
"phoneNumber"=>
[{"type"=>"home", "number"=>"212 555-1234"},
{"type"=>"fax", "number"=>"646 555-4567"}],
"gender"=>{"type"=>"male"},
"number"=>[10, 5, 4, 9, 7],
"tags"=>Set["staff", "engineer", {"joined_at"=>"2016", "emp_no"=>10}, "writer"]}
pp DeepSort.deep_sort(hash)
sort_enum: true
pp DeepSort.deep_sort(sort_enum: true)