OxL Reference

method List.sortBy

Stable sort by the natural order of key(x).

Example:

oxl✓ checked in CI
fn main() io {
  var words = ["pear", "fig", "apple"]
  words.sortBy(w => w.len())
  print("{words}")
}
Output
["fig", "pear", "apple"]
pub(api) var fn sortBy<K>(key: fn(T) -> K)

Since. 1.0.0-beta

Parameters

NameType
keyfn(T) -> K

Effects

none declared (pure unless the body says otherwise)

Defined in: std/core/text.oxl:1019

See also