I haven’t used table.sort before so excuse my lack of understanding, but I am trying to sort parts by their name, and it isn’t sorting them for some reason. I just need a bit of help understanding how table.sort works.
here’s my code
local parts = game.Workspace:FindFirstChild("epicparts"):GetChildren()
table.sort(parts, function(a,b)
print("folder a:"..a.Name.." folder b:"..b.Name)
return a.Name < b.Name
end)
while wait(1) do
if game.Workspace:FindFirstChild("epicparts") ~= nil then
local folder = game.Workspace:FindFirstChild("epicparts"):GetChildren()
table.sort(folder, function(a,b)
print("folder a:"..a.Name.." folder b:"..b.Name)
return a.Name < b.Name
end)
for i, v in ipairs(parts) do
for b, e in ipairs(folder) do
if v ~= e then
print(v.Name .." is not ".. e.Name)
end
end
end
else
game.Players.LocalPlayer:Kick()
end
end
here are the parts im trying to sort

here is the outcome
![]()
it says it sorted them, but they arent sorted