Skip to content
Merged
Prev Previous commit
Next Next commit
Update documentation for sort_by_key
  • Loading branch information
varkor committed Mar 16, 2018
commit 670e69e20753e2ef33ee61b0515092cace3fd716
11 changes: 4 additions & 7 deletions src/liballoc/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1302,11 +1302,9 @@ impl<T> [T] {

/// Sorts the slice with a key extraction function.
///
/// This sort is stable (i.e. does not reorder equal elements) and `O(n log n)` worst-case.
///
/// When applicable, unstable sorting is preferred because it is generally faster than stable
/// sorting and it doesn't allocate auxiliary memory.
/// See [`sort_unstable_by_key`](#method.sort_unstable_by_key).
/// During sorting, the key function is called only once per element.
/// This sort is stable (i.e. does not reorder equal elements) and `O(m n + n log n)`
/// worst-case, where the key function is `O(m)`.
///
/// # Current implementation
///
Expand All @@ -1315,8 +1313,7 @@ impl<T> [T] {
/// It is designed to be very fast in cases where the slice is nearly sorted, or consists of
/// two or more sorted sequences concatenated one after another.
///
/// Also, it allocates temporary storage half the size of `self`, but for short slices a
/// non-allocating insertion sort is used instead.
/// The algorithm allocates temporary storage the size of `self`.
Copy link

@ghost ghost Mar 1, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's be a bit more precise here. Temporary storage is a Vec<(K, usize)> of the same length as self.

///
/// # Examples
///
Expand Down