-
Notifications
You must be signed in to change notification settings - Fork 6.8k
bug(table-data-source): Sorting of a string column/property breaks if one record contains a number only #20140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Reproduction: https://stackblitz.com/edit/angular-xpwhup?file=src/app/table-sorting-example.ts Confirmed that this happens and that it's weird |
Hi! I could try to take care of that myself. The solution I propose is to compare the data type after the call to _isNumberValue, if one of them is numeric and the other string, it would convert the numeric value to string, so if both are numeric the sort by number would be kept (faster ) and if not it would be ordered by text. I did a test on the stackblitz mentioned by jelbourn and it would work |
Sort correctly when column information contains string and number values Fixes angular#20140
Sort correctly when column information contains string and number values Fixes angular#20140
Sort correctly when column information has string and numeric values Fixes angular#20140
Sort correctly when column information has string and numeric values Fixes angular#20140
Sort correctly when column information has string and numeric values
@andrewseguin thoughts? |
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 #20140 |
@jelbourn Please correct me if I am wrong. |
@stnor any views ?? |
LGTM |
…e 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
Hello, I still have the issue on Angular 13.3.3, value 058233665663 is not place well |
I probably fixed that #25444, @andrewseguin @crisbeto can u take a look? |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Reproduction
[edit, thanks @jelbourn]
https://stackblitz.com/edit/angular-xpwhup?file=src/app/table-sorting-example.ts
Expected Behavior
The sorting of strings should work as one expects when values are strings.
Actual Behavior
The sortingDataAccessor won't sort a string column correctly if one or more records contain a number only eg '1'.
Ex: ['One' ,'2', 'Three']
Suggested change
Use typeof value === 'number' instead of _isNumberValue perhaps, or something more elaborate?
Environment
The text was updated successfully, but these errors were encountered: