Re: weird behaviour of table.sort
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: weird behaviour of table.sort
- From: Ico Doornekamp <lua@...>
- Date: 2010年6月28日 19:56:28 +0200
* 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