-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Closed
Labels
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentAn issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Description
Bug
When sorting over a column of numbers the number zero is sorted incorreclty
Example:
What is the expected behavior?
0 should be larger than negative numbers
What is the current behavior?
0 is smaller than negative numbers
Is there anything else we should know?
The problem is probably here
https://github.com/angular/material2/blob/c05005a688a1ff929af966835ae33ca85c106fc9/src/lib/table/table-data-source.ts#L128-L139
0 evaluates to false, while it shouldn't in this case.
I think something along the lines of
if ((valueA || valueA === 0) && (valueB || valueB === 0)) {
// Check if one value is greater than the other; if equal, comparatorResult should remain 0.
if (valueA > valueB) {
comparatorResult = 1;
} else if (valueA < valueB) {
comparatorResult = -1;
}
} else if (valueA || valueA === 0) {
comparatorResult = 1;
} else if (valueB || valueB === 0) {
comparatorResult = -1;
}
should fix this issue
Metadata
Metadata
Assignees
Labels
P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentAn issue that is relevant to core functions, but does not impede progress. Important, but not urgent