[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Deterministic table iteration
- From: Javier Guerra Giraldez <javier@...>
- Date: Fri, 8 Feb 2013 15:49:04 -0500
On Fri, Feb 8, 2013 at 3:37 PM, Ivo Beltchev <email@example.com> wrote:
> I’d like to know in what cases I can count on deterministic order of table
> iteration. I’m pretty sure if the keys are objects that are stored in memory
> (like tables, threads, closures, or full user data), the order is not
> deterministic. But what if the keys are limited to simple types, like
> numbers, strings, booleans, light user data? Is the order going to be always
> the same?
no. if you want deterministic order, you can easily keep a copy of
the keys on the array part, like table.sort() result.