lua table.sort

注意问题

快排可能出现自己跟自己比较

这时候需要return false

文档解释

table.sort (table [, comp])


Sorts table elements in a given order, in-place, from table[1] to table[n], where n is the length of the table. If comp is given, then it must be a function that receives two table elements, and returns true when the first is less than the second (so that not comp(a[i+1],a[i]) will be true after the sort). If comp is not given, then the standard Lua operator < is used instead.


The sort algorithm is not stable; that is, elements considered equal by the given order may have their relative positions changed by the sort.

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 7,452评论 0 10
  • Lua 5.1 参考手册 by Roberto Ierusalimschy, Luiz Henrique de F...
    苏黎九歌阅读 13,921评论 0 38
  • 现在很多人标榜“要嫁给爱情”可爱情是什么呢?我不知道,更不知道父母之间的感情是爱情,亲情,亦或是友情。可是流淌在日...
    蔚然123阅读 826评论 0 0
  • numpy的数据类型 使用numpy 创建ndarrays 数据类型使用以及转换 ndarry 标量之间的计算• ...
    MicoCube阅读 980评论 0 1