[Space Lua] Fix: table.sort comparator returns 0 for ties, not 1

Returning `1` when the comparator yields `false`/`nil` declares `a > b`
for equal elements. `asyncQuickSort` tolerates this today but any future
sort algorithm change could corrupt results. Changed to `0` so ties are
neutral.

Signed-off-by: Matouš Jan Fialka <mjf@mjf.cz>
This commit is contained in:
Matouš Jan Fialka
2026-02-20 09:04:04 +01:00
parent af0086fcfb
commit 4d30baa2f2
2 changed files with 5 additions and 2 deletions
+3
View File
@@ -185,6 +185,9 @@ do
table.sort(t, function(a, b) return a > b end)
assertEqual(t, { 3, 2, 1 })
table.sort(t, function(a, b) return a < b end)
assertEqual(t, { 3, 2, 1 })
local data = { { name = "John", age = 30 }, { name = "Jane", age = 25 } }
table.sort(data, function(a, b) return a.age < b.age end)
assertEqual(data[1].name, "Jane")