lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


* On 2010-06-28 Wolfgang Pupp <wolfgang.pupp@gmail.com> wrote  :

> local function lesser(a, b)
>   assert(a and b)
>   return true
> end
> table.sort({1,2,3,4}, lesser)
> 
> The assertion fails- only if you remove it, you'll the expected
> 'invalid order function for sorting'- error.
> IMHO, it would be desirable to change this behaviour, that is, if a
> table does not contain nil- elements, the comparison function should
> never get nil as argument, either.

You broke the contract: your comparison function lies to table.sort(). So
why should table.sort() act reasonable to you ?

-- 
:wq
^X^Cy^K^X^C^C^C^C