How can I make a custom Sort Order?

I recently made the following script, which I want to make a custom SortOrder, which is sorted from old to newer. I still don’t know how to apply the custom of any Enum property, so I have no idea how to do it

local GridLayout = script.Parent:WaitForChild("UIGridLayout")

local function add()	
   for index, SortOrder in pairs(Enum.SortOrder:GetEnumItems()) do
		local Buttons = Instance.new("TextButton")
		Buttons.Name = SortOrder.Name
		Buttons.Text = SortOrder.Name
		Buttons.Parent = script.Parent
			
		Buttons.MouseButton1Click:Connect(function()
			GridLayout.SortOrder = Enum.SortOrder[SortOrder.Name]
		end)
	end
end
--start
add()

You could just use LayoutOrder and have a count which goes up when making new buttons.
And example would be like

local Button = script.Parent
local Count = 1

Button.LayoutOrder = Count
Count += 1
1 Like

Custom SortOrders no longer exist. You need to use any of the existing SortOrder options or create your own ruleset by using a LayoutOrder SortOrder and translating the rules of your sort into numbers that can be applied to LayoutOrder of each Gui element you want to sort.

6 Likes