lua-users home
lua-l archive

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


How does Lua handle sorting in tables where indexing values are non-numeric?

Example:

x={}

x.x = "x"

x.b = "b"

x.h = "h"

if I do a 'print(next(x,nil))' I usually get 'b' but if a add

x.a = "a" then I still get b - if I then do a 'x=sort(x)' I still get 'b' - but this is not nessesary the truth. Some times it behaves completely different. If I look at the sort routines, the hash routines etc. It looks to me that handling of non-numeric index values are not very well supported!

I need a fixed behavior so my program wont display different sortings to the users.

Any comments to this ??

With Regards,

Erik Hougaard