Skip to main content
Log in

Mojo function

sort

sort[: origin.set, T: Copyable & Movable, origin: MutableOrigin, //, cmp_fn: fn(T, T) capturing -> Bool, *, stable: Bool = False](span: Span[T, origin])

Sort the list inplace. The function doesn't return anything, the list is updated inplace.

Parameters:

  • T (Copyable & Movable): CollectionElement type of the underlying data.
  • origin (MutableOrigin): Origin of span.
  • cmp_fn (fn(T, T) capturing -> Bool): The comparison function.
  • stable (Bool): Whether the sort should be stable.

Args:

  • span (Span[T, origin]): The span to be sorted.

sort[: origin.set, origin: MutableOrigin, //, cmp_fn: fn(Int, Int) capturing -> Bool, *, stable: Bool = False](span: Span[Int, origin])

Sort the list inplace. The function doesn't return anything, the list is updated inplace.

Parameters:

  • origin (MutableOrigin): Origin of span.
  • cmp_fn (fn(Int, Int) capturing -> Bool): The comparison function.
  • stable (Bool): Whether the sort should be stable.

Args:

  • span (Span[Int, origin]): The span to be sorted.

sort[origin: MutableOrigin, //, *, stable: Bool = False](span: Span[Int, origin])

Sort the list inplace. The function doesn't return anything, the list is updated inplace.

Parameters:

  • origin (MutableOrigin): Origin of span.
  • stable (Bool): Whether the sort should be stable.

Args:

  • span (Span[Int, origin]): The span to be sorted.

sort[dtype: DType, origin: MutableOrigin, //, *, stable: Bool = False](span: Span[SIMD[dtype, 1], origin])

Sort the list inplace. The function doesn't return anything, the list is updated inplace.

Parameters:

  • dtype (DType): CollectionElement type of the underlying data.
  • origin (MutableOrigin): Origin of span.
  • stable (Bool): Whether the sort should be stable.

Args:

  • span (Span[SIMD[dtype, 1], origin]): The span to be sorted.

sort[T: Copyable & Movable & Comparable, origin: MutableOrigin, //, *, stable: Bool = False](span: Span[T, origin])

Sort list of the order comparable elements in-place.

Parameters:

  • T (Copyable & Movable & Comparable): The order comparable collection element type.
  • origin (MutableOrigin): Origin of span.
  • stable (Bool): Whether the sort should be stable.

Args:

  • span (Span[T, origin]): The span to be sorted.