Mojo function
sort
sort[T: Copyable, origin: MutOrigin, //, cmp_fn: fn(T, T) capturing -> Bool, *, stable: Bool = False, __disambiguate: NoneType = None](span: Span[T, origin])
Sort a span in-place. The function doesn't return anything, the span is updated in-place.
Parameters:
- T (
Copyable): Type of the underlying data. - origin (
MutOrigin): Origin of span. - cmp_fn (
fn(T, T) capturing -> Bool): The comparison function. - stable (
Bool): Whether the sort should be stable. - __disambiguate (
NoneType): Give the Scalar overload higher priority. Do not pass explicitly.
Args:
- span (
Span): The span to be sorted.
sort[dtype: DType, origin: MutOrigin, //, cmp_fn: fn(Scalar[dtype], Scalar[dtype]) capturing -> Bool, *, stable: Bool = False](span: Span[Scalar[dtype], origin])
Sort a span of Scalar elements in-place. The function doesn't return anything, the list is updated in-place.
Parameters:
- dtype (
DType): Type of elements. - origin (
MutOrigin): Origin of span. - cmp_fn (
fn(Scalar[dtype], Scalar[dtype]) capturing -> Bool): The comparison function. - stable (
Bool): Whether the sort should be stable.
Args:
- span (
Span): The span to be sorted.
sort[origin: MutOrigin, //, cmp_fn: fn(Int, Int) capturing -> Bool, *, stable: Bool = False](span: Span[Int, origin])
Sort a span in-place. The function doesn't return anything, the span is updated in-place.
Parameters:
- origin (
MutOrigin): Origin of span. - cmp_fn (
fn(Int, Int) capturing -> Bool): The comparison function. - stable (
Bool): Whether the sort should be stable.
Args:
- span (
Span): The span to be sorted.
sort[origin: MutOrigin, //, *, stable: Bool = False](span: Span[Int, origin])
Sort a span inplace. The function doesn't return anything, the span is updated in-place.
Parameters:
Args:
- span (
Span): The span to be sorted.
sort[T: Copyable & Comparable, origin: MutOrigin, //, *, stable: Bool = False](span: Span[T, origin])
Sort a span of comparable elements in-place.
Parameters:
- T (
Copyable&Comparable): The order comparable collection element type. - origin (
MutOrigin): Origin of span. - stable (
Bool): Whether the sort should be stable.
Args:
- span (
Span): The span to be sorted.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!