YAML and :SortKeys in 1.8.3


#1

What happened to this option in 1.8.3?

obj.to_yaml(:SortKeys => true)

as in:

irb(main):026:0> hh={“6”=>6, “11”=>11, “7”=>7}
=> {“11”=>11, “6”=>6, “7”=>7}
irb(main):027:0> puts(hh.to_yaml(:SortKeys => true))
“11”: 11
“6”: 6
“7”: 7

The code in the yaml lib that tested for this option has been removed. I
liked it…


#2

Joel VanderWerf wrote:

“6”: 6
“7”: 7

The code in the yaml lib that tested for this option has been removed. I
liked it…

Actually, I just reinstalled 1.8.2, and it doesn’t sort by keys either
in this example. A better example is

puts(ENV.to_hash.to_yaml(:SortKeys => true))

In 1.8.3, the output is not sorted, but it is sorted in 1.8.2.