-
Notifications
You must be signed in to change notification settings - Fork 14k
Closed
Description
In Rust code that uses Itertools I see code like
data.sorted().rev().take(3)...
Or more generally I see sorting + take. In such cases when the number of items to take is small it's better to use a faster algorithm that sorts only those few items. This is the partialSort() of the D language stdlib:
https://dlang.org/phobos/std_algorithm_sorting.html#partialSort
Currently in Rust this could be done efficiently using select_nth_unstable() followed by sort() of just the first items.
Metadata
Metadata
Assignees
Labels
No labels