Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

instance method

JSON::Ext::Generator::State#sort_keys=

sort_keys=(value)

value is a boolean or a proc. If the value is the boolean true, object keys will be sorted lexicographically in ascending order.

If the value is a proc, it receives the entire Hash and must return a Hash with its pairs in the desired order, allowing for arbitrary sorting.