I’ve been trying to sort a GridLayout putting frames with a “true” variable inside it and “false” ones after, but I couldn’t make it work, since I’ve tried :SortOrder, but it only checks strings numbers or enums… Is there a way to do this?
1 Like
Consider converting a boolean to a number
true → 1
false → 0
Ok now it prints an error: “SortOrder.Custom is deprecated, please switch to LayoutOrder”… ??
1 Like
Well, an alternative way of sorting this would be to name the frames 1 or 0 (depending on the boolean) and then the GridLayout should do its magic itself…
(also I’m pretty sure that error is an engine bug)
Yup it worked with the names thing, thanks!
That’s not an error, just a warning displayed by the linter. Here’s an alternative approach to the one suggested (uses ‘LayoutOrder’ instead of ‘Name’).
UIListLayout.SortOrder = "LayoutOrder" --Sort objects according to the value of their 'LayoutOrder' property (instead of their 'Name' property).
local Objects = {} --Array of objects.
table.sort(Objects, function(L, R) return L.BoolValue.Value end) --Assume each object contains a 'BoolValue' instance.
for Index, Object in ipairs(Objects) do
Object.LayoutOrder = Index --Set each object's 'LayoutOrder' property.
end