Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upbug(table-data-source): Sorting of a string column/property breaks if one record contains a number only #20140
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 |
Hugoer
added a commit
to Hugoer/components
that referenced
this issue
Jul 31, 2020
Sort correctly when column information contains string and number values Fixes angular#20140
Hugoer
added a commit
to Hugoer/components
that referenced
this issue
Jul 31, 2020
Sort correctly when column information contains string and number values Fixes angular#20140
Hugoer
added a commit
to Hugoer/components
that referenced
this issue
Jul 31, 2020
Sort correctly when column information has string and numeric values Fixes angular#20140
Hugoer
added a commit
to Hugoer/components
that referenced
this issue
Jul 31, 2020
Sort correctly when column information has string and numeric values Fixes angular#20140
Hugoer
added a commit
to Hugoer/components
that referenced
this issue
Jul 31, 2020
Sort correctly when column information has string and numeric values
|
@andrewseguin thoughts? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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