table.sort

smurf1k➹

Участник
Автор темы
78
67
Версия MoonLoader
.026-beta
Почему не сортирует?
Lua:
require 'moonloader'
local samp = require "samp.events"
font = renderCreateFont('Tahoma', 12, 5)
function main()
    while not isSampAvailable() do wait(200) end
    loh = {}
    while true do
        wait(0)
        x, y = 250, 500
        for k, v in pairs(loh) do
            table.sort(loh, comp)
            if v ~= nil then renderFontDrawText(font, v, x, y, -1) end
            y = y + renderGetFontDrawHeight(font)
        end
    end
end

function samp.onServerMessage(color, text)
    loh[math.random(0, 50)] = math.random(0, 50)
end

function comp(w1,w2)
    if (tonumber(w2) < tonumber(w1)) then
        return true
    end
end
 
Последнее редактирование: