Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to list integer values form least to greatest?

Asked by 3 years ago

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

Log in to vote
0
Answered by 3 years ago

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

0
You're a legend! I'll chuck this code into my game and see if it works. ZakOMGmcpe564 52 — 3y
0
Remember to change the values variable to the folder where you store your IntValues. Have fun! SpectacularPavlos 86 — 3y
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? ZakOMGmcpe564 52 — 3y
0
Just do game.ReplicatedStorage.Name of folder. SpectacularPavlos 86 — 3y
View all comments (2 more)
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? ZakOMGmcpe564 52 — 3y
0
Nevermind, I got it to work! Thanks for your help! ZakOMGmcpe564 52 — 3y
Ad

Answer this question