I’m making some different filters for a table in a project I’m working on and would like the player to be able to sort the items within by how recent they acquired them. How would I go about this?
I have other methods of sorting set up like by rarity or damage (I am using layout order to sort things) but am not sure how to set up a recency filter.
Here’s some of the code showing how I have filters working right now, as I’m not sure the method I’m using would allow for sorting by recency:
if method == "Rarity" then
currentFilter = "Rarity"
for i, cardIcon in pairs(cardsScroll:GetChildren()) do
if cardIcon:IsA("ImageButton") then
cardIcon.Visible = true
local cardRarity = CardInfo.Cards[cardIcon.Name].RarityForFilter
cardIcon.LayoutOrder = -cardRarity
end
end
elseif method == "Amount" then
currentFilter = "Amount"
for i, cardIcon in pairs(cardsScroll:GetChildren()) do
if cardIcon:IsA("ImageButton") then
cardIcon.Visible = true
local cardAmount = CardInfo.Cards[cardIcon.Name].CardAmount
cardIcon.LayoutOrder = -cardAmount
end
end
-- Just more similar filters past this