I have multiple numbers in my table. I want to get the smallest number. How can I do this?

I have this table
local MagnitudeList = {}
When there is a target in the table, it gets added with Magnitude with this script:

for Target, Value in pairs(TargetList) do
	table.insert(MagnitudeList, (Target.HumanoidRootPart.Position - script.Parent.Actor.PrimaryPart.Position).Magnitude)
	print((Target.HumanoidRootPart.Position - script.Parent.Actor.PrimaryPart.Position).Magnitude)
end

How can I sort everything in the table from smallest to greatest?

Thanks in advance!
WilliApple

You can use table.sort() table | Roblox Creator Documentation

local tab = {}
table.sort(tab,function(magA,magB)
      return magA < magB
end)

You don’t need to include the sort behavior because that’s the default.

table.sort(tab) does the same.