CC: Tweaked

CC: Tweaked

42M Downloads

table.sort not sorting specific tables

Shiranuit opened this issue ยท 0 comments

commented

Minecraft Version

1.19.x

Version

[1.19.2] 1.101.1

Details

This issue is mostly here to keep track of another issue with Cobalt until Cobalt has been fixed and updated inside CC:Tweaked.

The issue is about the sorting of specific tables like the following one reported here cc-tweaked/Cobalt#58 by @Wojbie

Here is the PR that should fix it cc-tweaked/Cobalt#63

Wrong behaviour described by @Wojbie

print("first")
local test = {"d","a","b","c"}
table.sort(test, function(a, b) return a < b end)
for k, v in ipairs(test) do
  print(k, v)
end
print("second")
local test = {[1]="d",[2]="a",[3]="b",[4]="c"}
table.sort(test, function(a, b) return a < b end)
for k, v in ipairs(test) do
  print(k, v)
end

image