From e4e79ff31cc76c1ac29f581f7b794fbdde1d9d68 Mon Sep 17 00:00:00 2001 From: Alex Martzios Date: Wed, 6 Jul 2022 12:49:16 +0300 Subject: [PATCH] fix for correct alphabetical in subjects array --- src/app/openaireLibrary | 2 +- src/app/subjects/subjects.component.ts | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/app/openaireLibrary b/src/app/openaireLibrary index db5c95f..ad15aaa 160000 --- a/src/app/openaireLibrary +++ b/src/app/openaireLibrary @@ -1 +1 @@ -Subproject commit db5c95fe248c0e4fe059602185ee8a6161d9949f +Subproject commit ad15aaae31acab823f624a64410f33c31d8526f7 diff --git a/src/app/subjects/subjects.component.ts b/src/app/subjects/subjects.component.ts index 02adab6..ba87365 100644 --- a/src/app/subjects/subjects.component.ts +++ b/src/app/subjects/subjects.component.ts @@ -148,8 +148,17 @@ export class SubjectsComponent { //this.getDivContents(); this.getPageContents(); this.subjects = community.subjects; - this.subjects.sort(); + console.log(this.subjects); + this.subjects.sort((a,b) => { + if(!a || a.toLocaleUpperCase() < b.toLocaleUpperCase()) { + return -1; + } else if (!b || a.toLocaleUpperCase() > b.toLocaleUpperCase()) { + return 1; + } + return 0; + }); this.groupSubjects(); + console.log(this.subjects); this.showLoading = false; } })); @@ -179,6 +188,10 @@ export class SubjectsComponent { })); } + // private sortSubjects(a, b) { + + // } + private groupSubjects() { if(this.subjects.length === 0) { return [];