LDDestroier

number sorter (cc)

Feb 16th, 2018
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.50 KB | None | 0 0
  1. math.sort = function(numlist)
  2.     local numbers = {}
  3.     for a = 1, #numlist do
  4.         if tonumber(numlist[a]) then
  5.             numbers[#numbers+1] = tonumber(numlist[a])
  6.         end
  7.     end
  8.     local output = {}
  9.     local nextnum
  10.     for a = 1, #numbers do
  11.         nextnum = math.min(table.unpack(numbers))
  12.         output[#output+1] = nextnum
  13.         for b = 1, #numbers do
  14.             if numbers[b] == nextnum then
  15.                 table.remove(numbers,b)
  16.                 break
  17.             end
  18.         end
  19.     end
  20.     return output
  21. end
  22.  
  23. local tArg = {...}
  24.  
  25. print(table.concat(math.sort(tArg),", "))
Add Comment
Please, Sign In to add comment