From bf8c6a9b7a36838be7df970f3b36d1521fd318db Mon Sep 17 00:00:00 2001 From: Tykayn Date: Wed, 17 Nov 2021 17:08:42 +0100 Subject: [PATCH] fix sort compare --- src/app/core/services/poll.service.ts | 2 +- .../administration/form/date/list/day/day-list.component.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/core/services/poll.service.ts b/src/app/core/services/poll.service.ts index 0a745321..68449c75 100644 --- a/src/app/core/services/poll.service.ts +++ b/src/app/core/services/poll.service.ts @@ -670,7 +670,7 @@ export class PollService implements Resolve { converted.push(this.DateUtilitiesService.convertDateToDateChoiceObject(someDate)); } this.dateChoiceList = converted.sort((first: any, second: any) => { - return second.date_object < first.date_object; + return first.date_object - second.date_object; }); return converted; diff --git a/src/app/features/administration/form/date/list/day/day-list.component.ts b/src/app/features/administration/form/date/list/day/day-list.component.ts index 3630e8f8..9f0aa02b 100644 --- a/src/app/features/administration/form/date/list/day/day-list.component.ts +++ b/src/app/features/administration/form/date/list/day/day-list.component.ts @@ -144,8 +144,8 @@ export class DayListComponent { this.dateUtilitiesService.addDaysToDate(1, lastDateChoiceObject) ) ); - this.pollService.dateChoiceList = this.pollService.dateChoiceList.sort((a: any, b: any) => { - return b.date_object < a.date_object; + this.pollService.dateChoiceList.sort((a: any, b: any) => { + return a.date_object - b.date_object; }); this.focusOnChoice(this.storageService.dateChoices.length - 1); }