[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: Sort problem
- From: "Virgil Smith" <Virgil@...>
- Date: Mon, 26 Jul 2004 12:27:23 -0500
Quick comment/curiosity...
does "return (a > b)" work?
This is different from "return not (a < b)".
-----Original Message-----
From: lua-bounces@bazar2.conectiva.com.br
[mailto:lua-bounces@bazar2.conectiva.com.br]On Behalf Of Michel Machado
Sent: Monday, July 26, 2004 11:21 AM
To: lua@bazar2.conectiva.com.br
Subject: Sort problem
Dears,
The code below (test.lua) fails:
t = {"a", "b", "a", "a"}
table.sort(t,
function (a, b)
assert(a ~= nil, "left var is nil!")
assert(b ~= nil, "right var is nil!")
return not (a < b) -- I want an inverted sort!
end)
for i, v in ipairs(t) do
print(i, v)
end
The error:
[michel@michel michel]$ lua test.lua
lua: test.lua:5: left var is nil!
stack traceback:
[C]: in function `assert'
test.lua:5: in function <test.lua:4>
[C]: in function `sort'
test.lua:3: in main chunk
[C]: ?
Did I make some mistake?
[ ]'s
Michel Machado