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()}")
}Вывод
["fig", "kiwi", "apple"]
pub(api) move fn sortBy<K: Ord, effect F>(key: fn(T) -> K F escaping) -> iter<T> FСложность. O(n log n); the whole input is pulled at the first pull.
С версии. 1.0.0-beta
Параметры
| Имя | Тип |
|---|---|
key | fn(T) -> K F escaping |
Возвращает
iter<T> F
Эффекты
не объявлены (чистая, пока тело не говорит иное)
Определено в: std/core/iter.oxl:512