Rearranges the array of strings in ascending order.
(a: &mut [T])
| 52 | { |
| 53 | /// Rearranges the array of strings in ascending order. |
| 54 | pub fn sort(a: &mut [T]) { |
| 55 | // Randomization. |
| 56 | // As with any quicksort, it is generally worthwhile to |
| 57 | // shuffle the array beforehand or to use a random paritioning |
| 58 | // item by swapping the first item with a random one. The primary |
| 59 | // reason to do so is to protect against worst-case performance |
| 60 | // in the case that the array is already sorted or nearly sorted. |
| 61 | common::util::shuffle(a); |
| 62 | let n = a.len(); |
| 63 | Self::do_sort(a, 0, n.saturating_sub(1), 0); |
| 64 | } |
| 65 | |
| 66 | /// 3-way string quicksort a[lo..hi] starting at d-th character |
| 67 | fn do_sort(a: &mut [T], lo: usize, hi: usize, d: usize) { |