I've been searching for answer to this question for a couple of days i manages to somehow use a trick to just omit this Concatenation part and just use several seperate loops to re-insert different values into the same table... but my question is
By default, table.sort uses < to compare array elements, so it can only sort arrays of numbers or arrays of strings. Write a comparison function that allows table.sort to sort arrays of mixed types. In the sorted array, all values of a given type should be grouped together. Within each such group, numbers and strings should be sorted as usual, and other types should be sorted in some arbitrary but consistent way.
A = { {} , {} , {} , "" , "a", "b" , "c" , 1 , 2 , 3 , -100 , 1.1 , function() end , function() end , false , false , true }
as i said i solved this using different for loops but is there a way to just analyse every element of the table then assign it to a different Table??? Like : "Tables,Funcs,Nums,Strings,..." then after analysing finished just concatenate them together to have the same table just in sorted version.
My Inefficient Answer To This Was :
function Sep(val)
local NewA = {}
for i in pairs(val) do
if type(val[i]) == "string" then
table.insert(NewA,val[i])
end
end
for i in pairs(val) do
if type(val[i]) == "number" then
table.insert(NewA,val[i])
end
end
for i in pairs(val) do
if type(val[i]) == "function" then
table.insert(NewA,tostring(val[i]))
end
end
for i in pairs(val) do
if type(val[i]) == "table" then
table.insert(NewA,tostring(val[i]))
end
end
for i in pairs(val) do
if type(val[i]) == "boolean" then
table.insert(NewA,tostring(val[i]))
end
end
for i in pairs(NewA) do
print(NewA[i])
end
end