Table.sort() issues with instances table

Hello everyone. I am having problems with table.sort(). I have table with frames that NOT nil and this table not sorted. I use these lines to sort this table

local function comp(Frame1 : Frame, Frame2 : Frame) return Frame1.LayoutOrder < Frame2.LayoutOrder end


local Frames = Menu:GetChildren() -- Not nil
local SortedFrames = table.sort(Frames, comp) -- is nil

Thanks for any help!

1 Like

My bad, just read documentation and realised that table.sort() returns nothing. :slight_smile:
fixed code:

local function comp(Frame1 : Frame, Frame2 : Frame) return Frame1.LayoutOrder < Frame2.LayoutOrder end


local Frames = Menu:GetChildren() -- Not nil
table.sort(Frames, comp) -- is Frames var
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.