@@ -4100,6 +4100,66 @@ impl<T, const N: usize> [[T; N]] {
4100
4100
}
4101
4101
}
4102
4102
4103
+ #[ cfg( not( bootstrap) ) ]
4104
+ #[ cfg( not( test) ) ]
4105
+ impl [ f32 ] {
4106
+ /// Sorts the slice of floats.
4107
+ ///
4108
+ /// This sort is in-place (i.e. does not allocate), *O*(*n* \* log(*n*)) worst-case, and uses
4109
+ /// the ordering defined by [`f32::total_cmp`].
4110
+ ///
4111
+ /// # Current implementation
4112
+ ///
4113
+ /// This uses the same sorting algorithm as [`sort_unstable_by`](slice::sort_unstable_by).
4114
+ ///
4115
+ /// # Examples
4116
+ ///
4117
+ /// ```
4118
+ /// #![feature(sort_floats)]
4119
+ /// let mut v = [2.6, -5e-8, f32::NAN, 8.29, f32::INFINITY, -1.0, 0.0, -f32::INFINITY, -0.0];
4120
+ ///
4121
+ /// v.sort_floats();
4122
+ /// let sorted = [-f32::INFINITY, -1.0, -5e-8, -0.0, 0.0, 2.6, 8.29, f32::INFINITY, f32::NAN];
4123
+ /// assert_eq!(&v[..8], &sorted[..8]);
4124
+ /// assert!(v[8].is_nan());
4125
+ /// ```
4126
+ #[ unstable( feature = "sort_floats" , issue = "93396" ) ]
4127
+ #[ inline]
4128
+ pub fn sort_floats ( & mut self ) {
4129
+ self . sort_unstable_by ( f32:: total_cmp) ;
4130
+ }
4131
+ }
4132
+
4133
+ #[ cfg( not( bootstrap) ) ]
4134
+ #[ cfg( not( test) ) ]
4135
+ impl [ f64 ] {
4136
+ /// Sorts the slice of floats.
4137
+ ///
4138
+ /// This sort is in-place (i.e. does not allocate), *O*(*n* \* log(*n*)) worst-case, and uses
4139
+ /// the ordering defined by [`f64::total_cmp`].
4140
+ ///
4141
+ /// # Current implementation
4142
+ ///
4143
+ /// This uses the same sorting algorithm as [`sort_unstable_by`](slice::sort_unstable_by).
4144
+ ///
4145
+ /// # Examples
4146
+ ///
4147
+ /// ```
4148
+ /// #![feature(sort_floats)]
4149
+ /// let mut v = [2.6, -5e-8, f64::NAN, 8.29, f64::INFINITY, -1.0, 0.0, -f64::INFINITY, -0.0];
4150
+ ///
4151
+ /// v.sort_floats();
4152
+ /// let sorted = [-f64::INFINITY, -1.0, -5e-8, -0.0, 0.0, 2.6, 8.29, f64::INFINITY, f64::NAN];
4153
+ /// assert_eq!(&v[..8], &sorted[..8]);
4154
+ /// assert!(v[8].is_nan());
4155
+ /// ```
4156
+ #[ unstable( feature = "sort_floats" , issue = "93396" ) ]
4157
+ #[ inline]
4158
+ pub fn sort_floats ( & mut self ) {
4159
+ self . sort_unstable_by ( f64:: total_cmp) ;
4160
+ }
4161
+ }
4162
+
4103
4163
trait CloneFromSpec < T > {
4104
4164
fn spec_clone_from ( & mut self , src : & [ T ] ) ;
4105
4165
}
0 commit comments