Hashes are unordered by definition. You have no control over how Ruby stores and returns the pairs. If you need an ordered data structure, use an Array.
Hope that helps.
James Edward Gray II
···
On May 14, 2005, at 3:26 PM, dave wrote:
how can I cast a YAML hash data into a ruby obj without
any auto-sort feature?
---
2: 1
1: 2
3: 3
how can I cast a YAML hash data into a ruby obj without
any auto-sort feature?
---
2: 1
1: 2
3: 3
James is correct. Neither Ruby nor YAML allows hashes to be ordered. However, Ruby's YAML library includes an Omap type[1], which acts like the ordered dictionaries you'll find in PHP.