On Aug 1, 10:56 pm, "d c" <lis... / pikkle.com> wrote:
> hi -
>
> i understand hashes dont keep their order in ruby, so wondering what the
> most elegant way to create some YAML that i want to maintain order is...
>
> for a simple menu system, i have a YAML file currently as:
>
> section1:
>   link1: home
>   link2: my page
>   link3: logout
>
> section2:
>   ... etc
>
> but after reading in thru YAML::load  this can come out as a different
> order. eg the logout button first...
>
> but to keep this as an array, it seems nasty to step thru and read
> pairs/skip in twos thru the array:
>
> section:
>  { link1, home, link2, mypage ... }
>
> on the subject, what do people like as a clear examples site? the spec does
> its best to make YAML as unreadable as XML...http://yaml.org/spec/current.html#id2540046
>
> http://yaml4r.sourceforge.net/cookbook/
> seems good
>
> thanks!

YAML has a secondary type called an omap. It is supported in the syck
implementation:

 section1: !omap
   - link1: home
   - link2: my page
   - link3: logout

The type is YAML::Omap.

T.