Closed bluecaret closed 4 years ago
The problem is that:
new Date(1978, 10, 12, 0, 0, 0, 0) == new Date(1978, 10, 12, 0, 0, 0, 0)
Will return false
.
Probably the solution would be to extend comparison functions and use Date's getTime()
before comparing two Dates
.
For now (before actual fix) you could pass your own comparator
that handles Date
s https://github.com/VadimDez/ngx-order-pipe#arguments
For example;
(a, b) => {
if (a instanceof Date) {
a = a.getTime();
b = b.getTime();
}
if (a === b) {
return 0;
}
if (a == null) {
return 1;
}
if (b == null) {
return -1;
}
return a > b ? 1 : -1;
}
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I have a strange issue that is causing my second column that needs to be sorted to be sorted in reverse order from the first.
Stackblitz: https://stackblitz.com/edit/ngx-order-pipe-njfy7p
In the example above it is sorted by DOB and then by Name. But the name column is in reverse order even though both should be ascending. If I sort by multiple columns with anything other than a date it seems to work fine.
Angular v7 ngx-order-pipe v2.0.4