[Wtr-general] OT-ish - What is determining the order this hash gets iterated through?
Paul Carvalho
tester.paul at gmail.com
Wed Jun 13 09:46:59 EDT 2007
Just remember that if you 'sort' a hash, you get an *array* not a hash. You
may need to adjust your code to match. That's tripped me up before.
On 12/06/07, Chris McMahon wrote:
>
> > So here's the question: Why aren't the csv results in the order of the
> hash?
> > And what order /are/ they in? There seems to be some method to the
> madness
> > here, because they come out consistently in the /same/ order...but it
> isn't
> > the order they are listed in the hash, or alphabetical by key or
> > value...anyone know how this works?
>
> Hashes are not sorted in predictable ways, regardless of which
> language you're using. Luckily, in Ruby, the Hash object has a sort()
> method: http://www.rubycentral.com/book/ref_c_hash.html#Hash.sort
>
> I'm not a huge expert at this stuff, but I've tripped over it before.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/wtr-general/attachments/20070613/26b000e7/attachment.html
More information about the Wtr-general
mailing list