Lua table.sort方法什么时候稳定?
我刚刚阅读了关于 Table.sort 的官方 Lua 文档并注意到它说:
“[Table.sort] 算法不稳定;也就是说,按给定顺序视为相等的元素可能会因排序而改变其相对位置。”
Table.sort
何时在 Lua 中变得稳定有什么想法吗?
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 Table.sort
will become stable in Lua?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不确定,但我认为你混淆了两个完全不同的东西:
排序算法的稳定性 (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.
稳定的排序算法比不稳定的排序稍微昂贵(就处理能力而言)。不稳定排序对于大多数应用程序来说是完全足够的。
除非有一个具体的计划将稳定的排序引入Lua,否则我会假设排序函数将保持原样。
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.