How To Sort Items By Price?

I’ve been trying to make a shop, which is going successful but the only problem I’m having is that I do not know how to make the items go in order by price. I’ve been researching all over the internet trying to figure out how to solve it but to no prevail. If you are willingly to help me it will be greatly appreciated!

Here’s a piece of code:
nani2

have you tried using table.sort after you have inserted the objects?

I was thinking about doing that but I’m not really sure how to code it

Here’s a thread that I found:

1 Like
table.sort(items , function(a , b)
	return a[2] > b[2]
end
3 Likes

Thanks!

30 letter 29348203948dafasdfasdf

1 Like

Here are some references for you:

https://www.lua.org/pil/19.3.html