I was just reading the official Lua documentation on Table.sort and noticed that it says:
"[Table.sort] algorithm is not stable; that is, elements considered equal by the given order may have their relative positions changed by the sort."
Any ideas when Ta开发者_开发技巧ble.sort
will become stable in Lua?
I'm not sure, but I think you're mixing up two completely different things:
Stability of a sorting algorithm (which is meant in the Lua reference)
and
Software stability aka. "bug freeness".
It won't, this is on purpose and best for performance.
Write your own if you really need a stable one.
A stable sorting algorithm is slightly more expensive (in terms of processing power) than an unstable sort. An unstable sort is perfectly adequate for most applications.
Unless there is a specific plan to introduce a stable sort into Lua, I would assume that the sort function will stay the way it is.
精彩评论