How do i sort all contents of a table by alphebatecal order

how do i do that because i dont know

Use table.sort

local exampleTable = {"banana", "apple", "orange", "pear", "grape"}

table.sort(exampleTable)

for _, fruit in exampleTable do
    print(fruit)
end

Output:

apple
banana
grape
orange
pear
1 Like

attempt to compare Instance < Instance
Is the erorr i get

Sorting an array of instances, you need to compare the name

So do this instead

table.sort(exampleTable, function(a.Name, b.Name)
    return a < b
end)

i dont understand what you mean

Your table has instances, if we are trying to sort them by alphabetical order, we need to compare their names. Thats how the table.sort function works. If you need extra help, send me the table you are working with.

local exampleTable = workspace:GetChildren()

table.sort(exampleTable, function(a0: Instance, a1: Instance)
	return a0.Name < a1.Name
end)

print(exampleTable)

You can read here to understand more:

at this point im gonan ask someone else to make this script i dont know anything about this

I think what @ahsanmoin05 said is about as easy as it gets! 5 lines of code is pretty cool when you consider how complicated a problem this is. Thankfully, many giants of computer programming have already done this stuff (and done it efficiently). @ahsanmoin05 presented it as simple as it can be…