SimpleQueryEngine does not sort on dates properly
Attempting to use SimpleQueryEngine to sort on Date values does not work properly because two Date objects that represent the same date are non-equal.
One potential reasonable solution is to sort using the valueOf
of a thing, if one exists:
for (var sort, i = 0; (sort = sortSet[i]); i++) {
var aValue = a[sort.attribute];
var bValue = b[sort.attribute];
// Use valueOf to enable proper comparison of Dates
aValue = aValue.valueOf ? aValue.valueOf() : aValue;
bValue = bValue.valueOf ? bValue.valueOf() : bValue;
if (aValue != bValue) {
return (Boolean(sort.descending) === (aValue == null || aValue > bValue)) ? -1 : 1;
}
}
return 0;
Change History (7)
Resolution: |
→ fixed
|
Status: |
new →
closed
|
1.9.1 is released; moving all outstanding tickets to next milestone.