|
马上注册,下载996引擎,与更多游戏开发者交流。
您需要 登录 才可以下载或查看,没有账号?注册
×
-- 初始化排行榜数据,模拟10个玩家的数据
local rankList = {
{player_name = "玩家1", score = 1000},
{player_name = "玩家2", score = 900},
{player_name = "玩家3", score = 850},
{player_name = "玩家4", score = 800},
{player_name = "玩家5", score = 780},
{player_name = "玩家6", score = 750},
{player_name = "玩家7", score = 10000},
{player_name = "玩家8", score = 680},
{player_name = "玩家9", score = 650},
{player_name = "玩家10", score = 8000}
}
-- 按照分数从高到低对排行榜进行排序
table.sort(rankList, function(a, b)
return a.score > b.score
end)
-- 展示排行榜数据
for index, player in ipairs(rankList) do
SL:print(index.. ". ".. player.player_name.. ": ".. player.score.. " 分")
end
|
|