@@ -1353,21 +1353,25 @@ impl<T> [T] {
1353
1353
///
1354
1354
/// # Current implementation
1355
1355
///
1356
- /// The current algorithm is an adaptive, iterative merge sort inspired by
1357
- /// [timsort](https://en.wikipedia.org/wiki/Timsort).
1358
- /// It is designed to be very fast in cases where the slice is nearly sorted, or consists of
1359
- /// two or more sorted sequences concatenated one after another.
1356
+ /// The current algorithm is based on [pattern-defeating quicksort][pdqsort] by Orson Peters,
1357
+ /// which combines the fast average case of randomized quicksort with the fast worst case of
1358
+ /// heapsort, while achieving linear time on slices with certain patterns. It uses some
1359
+ /// randomization to avoid degenerate cases, but with a fixed seed to always provide
1360
+ /// deterministic behavior.
1360
1361
///
1361
- /// The algorithm allocates temporary storage in a `Vec<(K, usize)>` the length of the slice.
1362
+ /// In the worst case, the algorithm allocates temporary storage in a `Vec<(K, usize)>` the
1363
+ /// length of the slice.
1362
1364
///
1363
1365
/// # Examples
1364
1366
///
1365
1367
/// ```
1366
- /// let mut v = [-5i32, 4, 1 , -3, 2];
1368
+ /// let mut v = [-5i32, 4, 32 , -3, 2];
1367
1369
///
1368
- /// v.sort_by_cached_key(|k| k.abs ());
1369
- /// assert!(v == [1, 2, -3, 4, -5 ]);
1370
+ /// v.sort_by_cached_key(|k| k.to_string ());
1371
+ /// assert!(v == [-3, -5, 2, 32, 4 ]);
1370
1372
/// ```
1373
+ ///
1374
+ /// [pdqsort]: https://github.com/orlp/pdqsort
1371
1375
#[ unstable( feature = "slice_sort_by_cached_key" , issue = "34447" ) ]
1372
1376
#[ inline]
1373
1377
pub fn sort_by_cached_key < K , F > ( & mut self , f : F )
0 commit comments