fork download
  1. scoreList = {
  2. {color="Red", score=40},
  3. {color="Green", score=12},
  4. {color="Orange", score=55},
  5. {color="Yellow", score=1},
  6. }
  7.  
  8. local sort_func = function(a,b) return a.score > b.score end
  9. table.sort(scoreList, sort_func)
  10.  
  11. for _, data in ipairs(scoreList) do
  12. print(data.color .. ": " .. data.score)
  13. end
Success #stdin #stdout 0s 4536KB
stdin
Standard input is empty
stdout
Orange: 55
Red: 40
Green: 12
Yellow: 1