# YAML and :SortKeys in 1.8.3

**URL:** <https://www.ruby-forum.com/t/yaml-and-sortkeys-in-1-8-3/48672>\
**Category:** Ruby\
**Created:** [November 23, 2005, 6:51am UTC](https://www.ruby-forum.com/t/yaml-and-sortkeys-in-1-8-3/48672 "2005-11-23T06:51:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vjoel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/e68b1a/32.png) [@vjoel](https://www.ruby-forum.com/u/vjoel)\
**Post date:** [November 23, 2005, 6:51am UTC](https://www.ruby-forum.com/t/yaml-and-sortkeys-in-1-8-3/48672/1 "2005-11-23T06:51:43Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![vjoel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/e68b1a/32.png) [@vjoel](https://www.ruby-forum.com/u/vjoel)\
**Post date:** [November 23, 2005, 7:03am UTC](https://www.ruby-forum.com/t/yaml-and-sortkeys-in-1-8-3/48672/2 "2005-11-23T07:03:51Z")

</div>

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.
