How To Sort Scrolling Frame

I’m making an inventory GUI (With a scrolling frame and an UIGridLayout), and I want it where whenever the Player equips a pet, the Pet will go to the first slot of the inventory. However I don’t really know how I would do this. After looking around, I still don’t really know how to accomplish this, but I think it has something to do with, UIGridLayout.LayoutOrder. Basically I just want to sort out the scrolling frame where the Equipped Pets will go first. Also the equipped Pets Image labels in the inventory have an Equipped value, if that helps with anything.

Set the UIGridLayout.SortOrder to LayoutOrder
Set the PetFrame.LayoutOrder to 0 if it’s equipped, and 1 if it’s unequipped

The equipped pets should appear before the unequipped ones

Article on LayoutOrder