method List.sortBy
Stable sort by the natural order of key(x).
Example:
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
| Name | Type |
|---|---|
key | fn(T) -> K |
Effects
none declared (pure unless the body says otherwise)
Defined in: std/core/text.oxl:1019