We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 37f4a7a commit e4102eaCopy full SHA for e4102ea
src/material/table/table-data-source.ts
@@ -148,6 +148,14 @@ export class MatTableDataSource<T> extends DataSource<T> {
148
let valueA = this.sortingDataAccessor(a, active);
149
let valueB = this.sortingDataAccessor(b, active);
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
+
159
// If both valueA and valueB exist (truthy), then compare the two. Otherwise, check if
160
// one value exists while the other doesn't. In this case, existing value should come last.
161
// This avoids inconsistent results when comparing values to undefined/null.
0 commit comments