How can I fix this?

I have this search GUI and I want it to sort the lowest prices higher and the larger prices lower.

sort script:

table.sort(Items:GetChildren(), function(A, B)
	
	if A:IsA("GuiButton") and B:IsA("GuiButton") then
		
		return (A.PurchaseItem.Values.ItemPrice.Value > B.PurchaseItem.Values.ItemPrice.Value)
		
	end
	
end)

Explorer:

What I see:

Thanks!

Try flipping that sign to <

Chars

1 Like

You are using the wrong comparison operator. The table.sort method, by default, is documented to use < for it’s sorting. That’s also the way to sort in ascending order, which it seems is what you want. Right now, with using >, you are sorting in descending order.

return (A.PurchaseItem.Values.ItemPrice.Value > B.PurchaseItem.Values.ItemPrice.Value)
									  --Change ^this to <
1 Like

Well, I guess I should have explained it more too lol.