fix for correct alphabetical in subjects array

This commit is contained in:
Alex Martzios 2022-07-06 12:49:16 +03:00
parent cd7a6722ac
commit e4e79ff31c
2 changed files with 15 additions and 2 deletions

@ -1 +1 @@
Subproject commit db5c95fe248c0e4fe059602185ee8a6161d9949f Subproject commit ad15aaae31acab823f624a64410f33c31d8526f7

View File

@ -148,8 +148,17 @@ export class SubjectsComponent {
//this.getDivContents(); //this.getDivContents();
this.getPageContents(); this.getPageContents();
this.subjects = community.subjects; 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(); this.groupSubjects();
console.log(this.subjects);
this.showLoading = false; this.showLoading = false;
} }
})); }));
@ -179,6 +188,10 @@ export class SubjectsComponent {
})); }));
} }
// private sortSubjects(a, b) {
// }
private groupSubjects() { private groupSubjects() {
if(this.subjects.length === 0) { if(this.subjects.length === 0) {
return []; return [];