From c2607473096b9d4efe43865bc82e6d09c476d0f6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lukas=20Mau=C3=9F?= <lukas.mauss@mni.thm.de>
Date: Fri, 2 Aug 2019 13:19:42 +0200
Subject: [PATCH] Adjust filtering/sorting so that they work in all browsers

---
 .../shared/comment-list/comment-list.component.ts  | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/app/components/shared/comment-list/comment-list.component.ts b/src/app/components/shared/comment-list/comment-list.component.ts
index 166503bbe..b8b71c936 100644
--- a/src/app/components/shared/comment-list/comment-list.component.ts
+++ b/src/app/components/shared/comment-list/comment-list.component.ts
@@ -256,13 +256,13 @@ export class CommentListComponent implements OnInit {
     this.filteredComments = this.comments.filter(c => {
       switch (type) {
         case this.correct:
-          return c.correct;
+          return c.correct ? 1 : 0;
         case this.favorite:
-          return c.favorite;
+          return c.favorite ? 1 : 0;
         case this.read:
-          return c.read;
+          return c.read ? 1 : 0;
         case this.unread:
-          return !c.read;
+          return !c.read ? 1 : 0;
       }
     });
     this.sortComments(this.currentSort);
@@ -271,13 +271,13 @@ export class CommentListComponent implements OnInit {
   sort(array: any[], type: string): void {
     array.sort((a, b) => {
       if (type === this.voteasc) {
-        return a.score - b.score;
+        return (a.score > b.score) ? 1 : (b.score > a.score) ? -1 : 0;
       } else if (type === this.votedesc) {
-        return b.score - a.score;
+        return (b.score > a.score) ? 1 : (a.score > b.score) ? -1 : 0;
       }
       const dateA = new Date(a.timestamp), dateB = new Date(b.timestamp);
       if (type === this.time) {
-        return +dateB - +dateA;
+        return (+dateB > +dateA) ? 1 : 0;
       }
     });
   }
-- 
GitLab