开发者

When will the Lua table.sort method become stable?

开发者 https://www.devze.com 2023-02-03 19:32 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号