Optimized members sort
This commit is contained in:
@@ -129,14 +129,18 @@ export default {
|
||||
},
|
||||
async loadMembers() {
|
||||
const response = await apiClient.get(`/clubmembers/get/${this.currentClub}/true`);
|
||||
this.members = response.data.sort(function(a, b) {
|
||||
if (!a.lastName) return -1;
|
||||
if (!b.lastName) return 1;
|
||||
if (a.lastName < b.lastName) return -1;
|
||||
if (a.lastName > b.lastName) return 1;
|
||||
if (a.firstName < b.firstName) return -1;
|
||||
if (a.firstName > b.firstName) return 1;
|
||||
return 0;
|
||||
this.members = response.data.sort((a, b) => {
|
||||
const lastNameA = a.lastName ? a.lastName.toLowerCase() : '';
|
||||
const lastNameB = b.lastName ? b.lastName.toLowerCase() : '';
|
||||
if (lastNameA && !lastNameB) return -1;
|
||||
if (!lastNameA && lastNameB) return 1;
|
||||
if (lastNameA && lastNameB) {
|
||||
const lastNameCompare = lastNameA.localeCompare(lastNameB, 'de-DE');
|
||||
if (lastNameCompare !== 0) return lastNameCompare;
|
||||
}
|
||||
const firstNameA = a.firstName ? a.firstName.toLowerCase() : '';
|
||||
const firstNameB = b.firstName ? b.firstName.toLowerCase() : '';
|
||||
return firstNameA.localeCompare(firstNameB, 'de-DE');
|
||||
});
|
||||
this.members.forEach(member => {
|
||||
this.loadMemberImage(member);
|
||||
|
||||
Reference in New Issue
Block a user