Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to list integer values form least to greatest?

I am new to coding and have been looking for a tutorial for this online forever. I've decided to ask it here. So, I have a folder with 12 integer values, and I want to find out how I can list them from biggest to smallest using a table?

1 answer

✓ Accepted answer

Do this

local values = folder where you store your IntValues
local sortedValues = {}

for _, v in pairs(values:GetChildren()) do
	table.insert(sortedValues, v.Value)
end

table.sort(sortedValues)

for number in ipairs(sortedValues) do
	print(number)
end

6 comments

0

You're a legend! I'll chuck this code into my game and see if it works.

0

Remember to change the values variable to the folder where you store your IntValues. Have fun!

0

Hey, I have a question: How do you change another folder with 12 different integer values to the table's contents depending on value?

0

Just do game.ReplicatedStorage.Name of folder.

0

Like, I want to loop through the table and change values in a DIFFERENT FOLDER than the one used in the script. Also, is this for a server script or a local script?

0

Nevermind, I got it to work! Thanks for your help!

This discussion is preserved as it was. New answers, comments, and votes are closed.