for A,S in pairs(mainFolder:GetChildren())do local x=S.Name if string.match(x,"\068\101\115\116\105\110\097\116\105\111\110 ")then table.insert(destinationList,x)end end local A={}repeat local S={nil;math.huge}for A,x in pairs(destinationList)do local v=string.split(destinationList[A]," ")local M=tonumber(v[2])if M<S[2]then S={A,M}end end table.insert(A,destinationList[S[1]])destinationList[S[1]]="\068\101\115\116\105\110\097\116\105\111\110 \057\057\057\057\057\057"until#A==#destinationList

for index, value in pairs(mainFolder:GetChildren()) do
	local valueName = value.Name
	if string.match(valueName, "Destination ") then
		table.insert(destinationList, valueName)
	end
end

local sortedList = {}
repeat -- Sort the list
	local lowestValue = {nil, math.huge}
	-- Table describing the index of the destination of the lowest value, followed by its value.
	for index, value in pairs(destinationList) do
		local nameSplit = string.split(destinationList[index], " ") -- Split the name to isolate its destination number
		local stringToNumber = tonumber(nameSplit[2]) -- Convert the destination number to an actual number
		if stringToNumber < lowestValue[2] then
			lowestValue = {index, stringToNumber} -- Overwrite the lowestValue table with the new lowest value.
		end
	end
	table.insert(sortedList, destinationList[lowestValue[1]]) -- Insert the lowest value into the sorted list
	destinationList[lowestValue[1]] = "Destination 999999" -- Don't remove the lowest value because it will end the loop early.
until #sortedList == #destinationList -- Repeat until the sorted list has all the destinations.
