gpt4 book ai didi

sorting - table.sort 使用什么算法?

转载 作者:行者123 更新时间:2023-12-04 17:36:03 27 4
gpt4 key购买 nike

我很好奇 Lua 的默认算法是什么 table.sort使用,只是因为它比我遇到的其他一些排序算法慢。我也很好奇 Lua 的 table.sort是在引擎中用 C 编写的,或者如果它在 Lua 中的库中。

最佳答案

What algorithm does table.sort use?


comment in tablib.c (向上滚动一点)状态
/*
** {======================================================
** Quicksort
** (based on `Algorithms in MODULA-3', Robert Sedgewick;
** Addison-Wesley, 1993.)
** =======================================================
*/
您可以在我提供的链接中阅读源代码。

I'm also curious if Lua's table.sort is written in the Engine in C, or if it's in a library in Lua.


此时,Lua 直接自带的所有库( iotablemath ,...)都是用 C 编写的。

关于sorting - table.sort 使用什么算法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18043803/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com