From 2eb97bc4f7ca98871bb9d843e60343d0aa1c7737 Mon Sep 17 00:00:00 2001 From: Steven Tischer Date: Tue, 2 Jun 2026 07:24:07 +0200 Subject: [PATCH] feat(backend/search): enhance sorting logic in person list by adding works count as a secondary criterion --- .../modules/person-list/person-list.component.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/webapp/src/app/modules/person-list/person-list.component.ts b/webapp/src/app/modules/person-list/person-list.component.ts index 5d91c5f7..bd63e6c1 100644 --- a/webapp/src/app/modules/person-list/person-list.component.ts +++ b/webapp/src/app/modules/person-list/person-list.component.ts @@ -72,12 +72,20 @@ export class PersonListComponent { return { ...response, - results: [...response.results].sort( - (a, b) => this.getSortRank(a) - this.getSortRank(b) - ), + results: [...response.results].sort((personA, personB) => { + const rankDiff = this.getSortRank(personA) - this.getSortRank(personB); + if (rankDiff !== 0) { + return rankDiff; + } + return this.getWorksCount(personB) - this.getWorksCount(personA); + }), }; } + getWorksCount(person: Author): number { + return person.works_count ?? 0; + } + getSortRank(person: Author): number { if (this.hasInstitution(person) && this.hasOrcid(person)) return 0; if (this.hasInstitution(person)) return 1;