Skip to content

Commit

Permalink
fix SortingUtil should not return -0
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Uhlmann committed Mar 21, 2021
1 parent 63d89e0 commit 39d94e6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/utils/SortingUtil.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export class SortingUtil {
static sortDescending(a: Date, b: Date) {
static sortDescending(a: Date, b: Date): number {
if (a > b) {
return -1;
} else if (a === b) {
Expand All @@ -9,7 +9,8 @@ export class SortingUtil {
}
}

static sortAscending(a: Date, b: Date) {
return -1 * this.sortDescending(a, b);
static sortAscending(a: Date, b: Date): number {
const res = -1 * this.sortDescending(a, b);
return Object.is(res, -0) ? 0 : res;
}
}

0 comments on commit 39d94e6

Please sign in to comment.