Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function essenceSort(t)
- local nt = {}
- for name, essence in pairs(t) do
- table.insert(nt, {
- name = name,
- essence = tonumber(essence)
- })
- end
- table.sort(nt, function(a, b)
- if a.essence > b.essence then
- return true
- elseif a.essence < b.essence then
- return false
- elseif a.name < b.name then
- return true
- else
- return false
- end
- end)
- return nt
- end
- -- To display:
- for _, v in ipairs(essenceSort(yourtable)) do
- echo(v.name .. ": " .. v.essence .. "\n")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement