Hello! I try to sort cases in table, which i recieved from modulescript. I have this cases:
["Case"] = {
["Basic"] = {
["Cost"] = 10,
["Name"] = "Basic case",
["ImageID"] = 1234567,
["Drop"] = {
["Basic"] = 80,
["Rare"] = 20,
["Super"] = 1
}
},
["Rare"] = {
["Cost"] = 20,
["Name"] = "Rare case",
["ImageID"] = 1234567,
["Drop"] = {
["Basic"] = 20,
["Rare"] = 80,
["Super"] = 3
}
},
["Cool"] = {
["Cost"] = 40,
["Name"] = "Super case",
["ImageID"] = 1234567,
["Drop"] = {
["Basic"] = 0,
["Rare"] = 60,
["Super"] = 40
}
},
["Imagine"] = {
["Cost"] = 100,
["Name"] = "Godly case",
["ImageID"] = 1234567,
["Drop"] = {
["Basic"] = 0,
["Rare"] = 0,
["Super"] = 100
}
},
}
I need to sort it from lower to higher by it’s cost and make a frame with it. Here’s my frame making code:
local rq = require(game.ReplicatedStorage.Modules[""])
local cnt = 1
function sortTable(a, b)
return a["Cost"] < b["Cost"]
end
local norm = rq.Case
table.sort(norm, sortTable)
for _,case in norm do
print(case)
local frm = game.StarterGui.Frame:Clone()
frm.Parent = script.Parent
frm.TextLabel.Text = case.Name
frm.ImageLabel.Image = case.ImageID
frm.TextLabe.Text = case.Cost
if cnt == 4 then cnt = 1 end
frm.Position = UDim2.new((0.015+0.3*(cnt-1)),0,(0.03+(0.25*math.round(#script.Parent:GetChildren()/3-1))),0)
cnt += 1
print(frm.Position)
end
But here’s the frame’s i getting:
I wanna frame’s to be like: 10,20,40,100, not reversed. How to do it?