Table slots disordered

I’m filling slots to a table like
WattTable[getdatetime()] <- Watt;
where getdatetime() is function to set a timestamp like TS20130624175411for the index and a value like 330.
In my opinion new slots should be added to the table at last position.
But they are anywhere, for me there is no strategie.

Can I do something that slots are sorted as they where added or is there way to sort a table?
I did’nt found a function in the Squirel docs, but possible someone have an idea.

Daniel

It looks like what you want is an array, not a table. Try this:

WattTable.push(Watt);

If you need to also store the datetime value, you could store and array of tables:

WattTable.push({ timestamp = getdatetime(), watts = Watt });

Thanks a lot, everything is working as expected now :slight_smile:

Awesome!