lua-users home
lua-l archive

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


On Mon, Jan 4, 2021 at 2:09 AM Jonathan Goble wrote:
Every sort function I've ever seen has undefined behavior when you introduce NaNs

Numbers with NaN is just the simplest example.
The same problem will be observed with table.sort() on many other partially ordered sets (using custom sort function).


Don't feed NaNs to a sort function

Why not?
The Lua manual claims that table.sort() can work with partially ordered sets.
Probably it should not have promised that :-)


BTW, why doesn't table.sort() return the table anymore as it was in Lua 5.1?