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; }