-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
fix(table): empty string should be sorted right #8011
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, add merge-ready when ready
src/lib/table/table-data-source.ts
Outdated
|
||
// If the value is a string and only whitespace, return the value. | ||
// Otherwise +value will convert it to 0. | ||
if (typeof value === 'string' && !value.trim()) { return value; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This conditional is a bit long to be single-lined
@Bsujeet What you are looking for is a stable sort, but the ES7 spec does not specify that native sorting must be stable. Each browser has its own way of sorting when array.sort is called and there's no consistency. For a stable sort, you'll want to adjust your comparator to account for the object's index if the comparison is equal. For some discussion on how to do this, try starting with this StackOverflow question. |
Thanks it was helpfull |
I have 5.0.0 and I still have this issue. In which release has this been released ? |
Should be out already - feel free to open an issue with reproduction steps so we can investigate if the issue persists |
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. |
Previously, an empty string gets converted to 0 and comes after other values. E.g. ' ' would come after 'x'.
Fixes #7460