diff --git a/src/main/webapp/app/lecture/lecture.component.ts b/src/main/webapp/app/lecture/lecture.component.ts index a6420ef17e7a..093ae0aa801b 100644 --- a/src/main/webapp/app/lecture/lecture.component.ts +++ b/src/main/webapp/app/lecture/lecture.component.ts @@ -121,14 +121,7 @@ export class LectureComponent implements OnInit { } sortRows() { - //Sort alphabetically for title and description - if (this.predicate === 'title') - this.filteredLectures = this.filteredLectures.sort((a: Lecture, b: Lecture) => (this.ascending ? a.title!.localeCompare(b.title!) : b.title!.localeCompare(a.title!))); - else if (this.predicate === 'description') - this.filteredLectures.sort((a: Lecture, b: Lecture) => - this.ascending ? (a.description || '').localeCompare(b.description || '') : (b.description || '').localeCompare(a.description || ''), - ); - else this.sortService.sortByProperty(this.filteredLectures, this.predicate, this.ascending); + this.sortService.sortByProperty(this.filteredLectures, this.predicate, this.ascending); } private loadAll() { diff --git a/src/main/webapp/app/shared/service/sort.service.ts b/src/main/webapp/app/shared/service/sort.service.ts index c9b77ef66f96..955bb36fcb70 100644 --- a/src/main/webapp/app/shared/service/sort.service.ts +++ b/src/main/webapp/app/shared/service/sort.service.ts @@ -87,7 +87,9 @@ export class SortService { } private static compareBasic(valueA: any, valueB: any) { - if (valueA === valueB) { + if (typeof valueA === 'string' && typeof valueB === 'string') { + return valueA.localeCompare(valueB); + } else if (valueA === valueB) { return 0; } else { return valueA < valueB ? -1 : 1;