@@ -1064,11 +1064,17 @@ impl<T> [T] {
1064
1064
1065
1065
/// This is equivalent to `self.sort_by(|a, b| a.cmp(b))`.
1066
1066
///
1067
- /// This sort is stable and `O(n log n)` worst-case.
1067
+ /// This sort is stable (i.e. does not reorder equal elements) and `O(n log n)` worst-case.
1068
1068
///
1069
- /// # Current Implementation
1069
+ /// # Current implementation
1070
1070
///
1071
- /// The current implementation allocates temporary storage half the size of `self`.
1071
+ /// The current algorithm is an adaptive, iterative merge sort inspired by
1072
+ /// [timsort](https://en.wikipedia.org/wiki/Timsort).
1073
+ /// It is designed to be very fast in cases where the slice is nearly sorted, or consists of
1074
+ /// two or more sorted sequences concatenated one after another.
1075
+ ///
1076
+ /// Also, it allocates temporary storage half the size of `self`, but for short slices a
1077
+ /// non-allocating insertion sort is used instead.
1072
1078
///
1073
1079
/// # Examples
1074
1080
///
@@ -1086,11 +1092,19 @@ impl<T> [T] {
1086
1092
self . sort_by ( |a, b| a. cmp ( b) )
1087
1093
}
1088
1094
1089
- /// Sorts the slice, in place, using `f` to extract a key by which to
1090
- /// order the sort by.
1095
+ /// Sorts the slice using `f` to extract a key to compare elements by.
1096
+ ///
1097
+ /// This sort is stable (i.e. does not reorder equal elements) and `O(n log n)` worst-case.
1098
+ ///
1099
+ /// # Current implementation
1100
+ ///
1101
+ /// The current algorithm is an adaptive, iterative merge sort inspired by
1102
+ /// [timsort](https://en.wikipedia.org/wiki/Timsort).
1103
+ /// It is designed to be very fast in cases where the slice is nearly sorted, or consists of
1104
+ /// two or more sorted sequences concatenated one after another.
1091
1105
///
1092
- /// This sort is stable and `O(n log n)` worst-case , but allocates
1093
- /// temporary storage half the size of `self` .
1106
+ /// Also, it allocates temporary storage half the size of `self` , but for short slices a
1107
+ /// non-allocating insertion sort is used instead .
1094
1108
///
1095
1109
/// # Examples
1096
1110
///
@@ -1108,11 +1122,19 @@ impl<T> [T] {
1108
1122
self . sort_by ( |a, b| f ( a) . cmp ( & f ( b) ) )
1109
1123
}
1110
1124
1111
- /// Sorts the slice, in place, using `compare` to compare
1112
- /// elements.
1125
+ /// Sorts the slice using `compare` to compare elements.
1126
+ ///
1127
+ /// This sort is stable (i.e. does not reorder equal elements) and `O(n log n)` worst-case.
1128
+ ///
1129
+ /// # Current implementation
1130
+ ///
1131
+ /// The current algorithm is an adaptive, iterative merge sort inspired by
1132
+ /// [timsort](https://en.wikipedia.org/wiki/Timsort).
1133
+ /// It is designed to be very fast in cases where the slice is nearly sorted, or consists of
1134
+ /// two or more sorted sequences concatenated one after another.
1113
1135
///
1114
- /// This sort is stable and `O(n log n)` worst-case , but allocates
1115
- /// temporary storage half the size of `self` .
1136
+ /// Also, it allocates temporary storage half the size of `self` , but for short slices a
1137
+ /// non-allocating insertion sort is used instead .
1116
1138
///
1117
1139
/// # Examples
1118
1140
///
0 commit comments