Advertisement
rhn

Test

rhn
Apr 2nd, 2020
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.50 KB | None | 0 0
  1. testlist={{"item1",2,3,2},{"item2",3,2,2},{"item3",3,2,1},{"item4",1,1,2},{"item5",1,1,1},{"item6",2,1,1},{"item7",2,1,2}}
  2. print(textutils.serialize(testlist))
  3. sleep(3)
  4. print("-----------------------")
  5. table.sort(testlist, function(a,b) return a[2]<b[2] end)
  6.  
  7.  
  8.  
  9. table.sort(testlist, function(a,b)
  10.         for i=2,4 do
  11.             if a[i]<b[i] then return true end
  12.             if a[i]>b[i] then return false end
  13.         end
  14.         end)
  15.  
  16.  
  17.  
  18.  
  19. for i=1,#testlist do
  20.     print(testlist[i][1])
  21. end
  22. --print(textutils.serialize(testlist))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement