Forum: Ruby YAML and :SortKeys in 1.8.3

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
47b1910084592eb77a032bc7d8d1a84e?d=identicon&s=25 vjoel (Guest)
on 2005-11-23 06:51
(Received via mailing list)
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...
47b1910084592eb77a032bc7d8d1a84e?d=identicon&s=25 vjoel (Guest)
on 2005-11-23 07:03
(Received via mailing list)
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.
This topic is locked and can not be replied to.