From 573fea070840ba3326c4f0278ae62ea57c6c7310 Mon Sep 17 00:00:00 2001 From: Chneemann Date: Sun, 31 Mar 2024 09:15:58 +0200 Subject: [PATCH] bugfixes sort function --- src/app/components/contacts/contacts.component.html | 2 +- src/app/components/contacts/contacts.component.ts | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/app/components/contacts/contacts.component.html b/src/app/components/contacts/contacts.component.html index b65de8d..1270cb4 100644 --- a/src/app/components/contacts/contacts.component.html +++ b/src/app/components/contacts/contacts.component.html @@ -10,7 +10,7 @@
- @for (sortLetter of this.checkUsersFirstLetter(); track sortLetter) { + @for (sortLetter of this.sortFirstLetter(); track sortLetter) {
{{ sortLetter }}
@for (user of this.sortUsersByFirstLetter(sortLetter); track user; let diff --git a/src/app/components/contacts/contacts.component.ts b/src/app/components/contacts/contacts.component.ts index 893a2ac..7647006 100644 --- a/src/app/components/contacts/contacts.component.ts +++ b/src/app/components/contacts/contacts.component.ts @@ -55,13 +55,12 @@ export class ContactsComponent { ); } - checkUsersFirstLetter() { + sortFirstLetter() { + let filteretArray = this.loadAllUserWithoutGuest().sort((a, b) => + a.firstName.localeCompare(b.firstName) + ); let usersFirstLetter = Array.from( - new Set( - this.loadAllUserWithoutGuest().map((user) => - user.firstName[0].toUpperCase() - ) - ) + new Set(filteretArray.map((user) => user.firstName[0].toUpperCase())) ); return usersFirstLetter; }