Add a "Vec.sorted()" function

One way to get first-k-of-n in O(n + k log(n)) is to use BinaryHeap::from(the_vec).into_sorted_iter(), since that from is O(n). (I don't remember if into_sorted_iter() actually got added; if not then it's iter::from_fn(|| the_heap.pop()).)

2 Likes