local GameCards = { 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D, --方块 A - K 0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D, --梅花 A - K 0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D, --红桃 A - K 0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D, --黑桃 A - K } GroupCards = {{33,25,24}, {3, 4, 5}} 从GameCards表中取一个二维数组GroupCards 怎么对GroupCards进行排序输出
时间: 2023-07-27 11:21:44 浏览: 98
Overview of The New C++ (C++0x) 英文版 PDF 非扫描版
5星 · 资源好评率100%
你可以使用 table.sort 函数对 GroupCards 进行排序,具体代码如下:
```
table.sort(GroupCards, function(a, b)
local aMax = math.max(unpack(a))
local bMax = math.max(unpack(b))
return aMax > bMax
end)
for i, v in ipairs(GroupCards) do
print("GroupCards[" .. i .. "]: {" .. table.concat(v, ", ") .. "}")
end
```
这段代码会按照每个数组中最大值的降序对 GroupCards 进行排序,并输出排序后的结果。
阅读全文