method iter.sortBy
Stable ascending sort by key (a barrier: the whole input is pulled at the first pull).
Example:
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> FComplexity. O(n log n); the whole input is pulled at the first pull.
Since. 1.0.0-beta
Parameters
| Name | Type |
|---|---|
key | fn(T) -> K F escaping |
Returns
iter<T> F
Effects
none declared (pure unless the body says otherwise)
Defined in: std/core/iter.oxl:512