OxL Reference

method iter.sortBy

Stable ascending sort by key (a barrier: the whole input is pulled at the first pull).

Example:

oxl✓ checked in CI
fn main() io {
  print("{["fig", "apple", "kiwi"].iter().sortBy(s => s.len()).collect()}")
}
Output
["fig", "kiwi", "apple"]
pub(api) move fn sortBy<K: Ord, effect F>(key: fn(T) -> K F escaping) -> iter<T>  F

Complexity. O(n log n); the whole input is pulled at the first pull.

Since. 1.0.0-beta

Parameters

NameType
keyfn(T) -> K F escaping

Returns

iter<T> F

Effects

none declared (pure unless the body says otherwise)

Defined in: std/core/iter.oxl:512

See also