Skip to content

Commit 1a9feda

Browse files
committed
同步utility
1 parent 7d2156d commit 1a9feda

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

script/utility.lua

+18-2
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,21 @@ function m.sortCallbackOfIndex(arr)
693693
end
694694
end
695695

696+
---@param datas any[]
697+
---@param scores integer[]
698+
---@return SortByScoreCallback
699+
function m.sortCallbackOfScore(datas, scores)
700+
local map = {}
701+
for i = 1, #datas do
702+
local data = datas[i]
703+
local score = scores[i]
704+
map[data] = score
705+
end
706+
return function (v)
707+
return map[v]
708+
end
709+
end
710+
696711
---裁剪字符串
697712
---@param str string
698713
---@param mode? '"left"'|'"right"'
@@ -851,12 +866,13 @@ function m.multiTable(count, default)
851866
end })
852867
end
853868
for _ = 3, count do
869+
local tt = current
854870
current = setmetatable({}, { __index = function (t, k)
855871
if k == nil then
856872
return nil
857873
end
858-
t[k] = current
859-
return current
874+
t[k] = tt
875+
return tt
860876
end })
861877
end
862878
return current

0 commit comments

Comments
 (0)