实现排序功能。
您可以从包中导入这些 API。例如:algorithm
from algorithm.sort import sort
partitionpartition[type: AnyRegType, cmp_fn: fn[AnyRegType]($0, $0, /) capturing -> Bool](buff: Pointer[*"type", 0], k: Int, size: Int)
对输入向量进行就地分区,使前 k 个元素是最大(如果cmp_fn 是 <= 运算符,则为最小)元素。前 k 个元素的顺序是未定义的。
参数:
AnyRegTypefn[AnyRegType]($0, $0, /) capturing -> Bool参数:
Pointer[*"type", 0]IntIntsortsort(inout buff: Pointer[Int, 0], len: Int)
对向量进行就地排序。
该函数不返回任何内容,向量就地更新。
参数:
Pointer[Int, 0]Intsort[type: DType](inout buff: Pointer[SIMD[type, 1], 0], len: Int)
对向量进行就地排序。
该函数不返回任何内容,向量就地更新。
参数:
DType参数:
Pointer[SIMD[type, 1], 0]Intsort(inout v: List[Int])
对向量进行就地排序。
该函数不返回任何内容,向量就地更新。
参数:
List[Int]sort[type: DType](inout v: List[SIMD[type, 1]])
对向量进行就地排序。
该函数不返回任何内容,向量就地更新。
参数:
DType参数:
List[SIMD[type, 1]]来源:Mojo中文网:mojocn.org Mojo Dev社区:mojoo.org