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).
partition
def partition[T: Copyable, origin: MutOrigin, //](span: Span[T, origin], k: Int, cmp_fn: T) where identical(T.T, T)
Partition the input buffer inplace such that first k elements are the largest (or smallest if cmp_fn is < operator) elements. The ordering of the first k elements is undefined.
Parameters:
Args:
- span (
Span[T, origin]): Input buffer. - k (
Int): Index of the partition element. - cmp_fn (
T): The comparison function.