I have an interesting problem (I think) and would love some help.
I am returning an Observable[DisplayCard[]] that is filtered based on a value. That all works great. After I filter that array based on a value, I NOW want to sort the returned array by another one of it's values called category. category can only be one of three String values: ONGOING, UPCOMING, and PAST.
I want to return an array that will sort like this: ONGOING --> UPCOMING --> PAST. So, all the display cards that have "ONGOING" will be in front, after there is no more of those, I want all the "UPCOMING" cards and then after those, I want all the "PAST" cards to show.
Here is my code:
displayCommunityCards$ = this.cardService.displayCards$
.pipe(
map(communityEventsCards => communityEventsCards.filter(community => community.type === 'COMMUNITY EVENT')
.sort((a, b) => {
return ???
}),
tap(data => console.log('Community Cards: ', JSON.stringify(data))),
);
