Hi everyone,
I’m somewhat new to coding in LUA. I just need to sort some data by date. I’ve attached what I have so far. I can sort by month but its not sorting by day.
I want to sort from newest to oldest. I’m sorting a lot of files so it needs to be fast.
I’m willing to pay you via paypal for your help.
The code is below.
local runAgain = false
local function sortTable(tbl)
for i = 2, #fileInfo -1 do
–keep a temporary backup
local temp = fileInfo[i];
–do checks
if fileInfo[i - 1].creationTime.year > fileInfo[i].creationTime.year and fileInfo[i - 1].creationTime.month > fileInfo[i].creationTime.month and fileInfo[i - 1].creationTime.day > fileInfo[i].creationTime.day and fileInfo[i - 1].creationTime.hour > fileInfo[i].creationTime.hour and fileInfo[i - 1].creationTime.min > fileInfo[i].creationTime.min and fileInfo[i - 1].creationTime.second > fileInfo[i].creationTime.second then
–swap items
fileInfo[i] = fileInfo[i - 1];
fileInfo[i - 1] = temp;
–set boolean
runAgain = true;
end
–reset
if i == #fileInfo -1 and runAgain == true then
i = 1;
runAgain = false;
break
end
end
end
[import]uid: 40156 topic_id: 10238 reply_id: 310238[/import]