IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /docs/manual/basics.md). For the complete Mojo documentation index, see llms.txt.
Skip to main content
Version: Nightly
For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).

sort

def sort[T: Copyable, origin: MutOrigin, //, *, stable: Bool = False](span: Span[T, origin], cmp_fn: T) where identical(T.T, T)

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.
  • stable (Bool): Whether the sort should be stable.

Args:

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

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

Sort a span of comparable elements in-place.

Parameters:

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

Args: