lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Every Lua table consist in a C array together with a hash table (but
both can be empty).
 - Consecutive integer indexes starting from 1 are stored in the array part
 - All other indexes are hashed and stored in the hash table part

The hash array is by nature unsorted. It is impossible to get back the
same order as the construction.
If you need it, you must use numeric indexes (a sequence), or an
associated array with keys order.

Example:
mydata = {
 { "key1",  "value1" },
  { "key2",  "value2" }
}

Or :

mytable_keys = { "key1", "key2" }