lua-users home
lua-l archive

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


Greetings again.

Is there any way I can preserve the order of items in a table?

For example, if I do:

    tbl = { a=1, b=2, c=3 }
    for i,v in tbl do
        print(i,v)
    end

Then I get:

a       1
c       3
b       2

Note I do not want the table alpha (or otherwise) sorted; I need
to be able to get back the items in the same order as they were
added when tbl was initialised.

Thanks.

Love, Light and Peace,
- Peter Loveday
eyeon Software