Skip to content

Commit 95a9c26

Browse files
committed
fix(material/table): Sorting of a string column/property breaks if one record contains a number only
If the number is a string and in between strings we treat it as a number and group it at the start/end of the table based on it's ascending or descending. I have fixed the issue in my commit here and I think it will work properly. Fixes angular#20140
1 parent 40002b7 commit 95a9c26

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/material/table/table-data-source.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ export class _MatTableDataSource<T,
183183
if (valueAType !== valueBType) {
184184
if (valueAType === 'number') { valueA += ''; }
185185
if (valueBType === 'number') { valueB += ''; }
186+
if ( (valueAType === 'string') && (_isNumberValue(valueA) === true) ) { valueA += ''; }
187+
if ( (valueBType === 'string') && (_isNumberValue(valueB) === true) ) { valueB += ''; }
186188
}
187189

188190
// If both valueA and valueB exist (truthy), then compare the two. Otherwise, check if

0 commit comments

Comments
 (0)