File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -148,6 +148,14 @@ export class MatTableDataSource<T> extends DataSource<T> {
148
148
let valueA = this . sortingDataAccessor ( a , active ) ;
149
149
let valueB = this . sortingDataAccessor ( b , active ) ;
150
150
151
+ const valueAType = typeof valueA ;
152
+ const valueBType = typeof valueB ;
153
+ const sameType = valueAType === valueBType ;
154
+ if ( ! sameType ) {
155
+ valueA = valueAType === 'number' ? valueA . toString ( ) : valueA ;
156
+ valueB = valueBType === 'number' ? valueB . toString ( ) : valueB ;
157
+ }
158
+
151
159
// If both valueA and valueB exist (truthy), then compare the two. Otherwise, check if
152
160
// one value exists while the other doesn't. In this case, existing value should come last.
153
161
// This avoids inconsistent results when comparing values to undefined/null.
You can’t perform that action at this time.
0 commit comments