local function sortedPlayers()
local tbl = {}
for _, ply in ipairs(player.GetAll()) do
if IsValid(ply) and not ply:IsBot() then
table.insert(tbl, ply)
end
end
table.sort(tbl, function(a, b)
-- 1. По рангу (выше — выше)
local ra = RANK_LIST[a:GetNWString("kdm1e_Rank", "user")] or RANK_LIST["user"]
local rb = RANK_LIST[b:GetNWString("kdm1e_Rank", "user")] or RANK_LIST["user"]
if ra.level ~= rb.level then return ra.level > rb.level end
-- 2. По убийствам
local ka = a:GetNWInt("PersistentKills", a:Frags())
local kb = b:GetNWInt("PersistentKills", b:Frags())
if ka ~= kb then return ka > kb end
-- 3. По нику
return a:Nick() < b:Nick()
end)
return tbl
end