From 91dec2370b189423b9176066bb939321411ded5d Mon Sep 17 00:00:00 2001 From: Maximilian Krambach Date: Sat, 19 Jan 2019 10:26:56 +0100 Subject: [PATCH] move empty/undefined sortings always to the alphabet's end --- client/src/app/core/services/sort-list.service.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/client/src/app/core/services/sort-list.service.ts b/client/src/app/core/services/sort-list.service.ts index f8b1308d8..e25287a69 100644 --- a/client/src/app/core/services/sort-list.service.ts +++ b/client/src/app/core/services/sort-list.service.ts @@ -209,13 +209,19 @@ export abstract class SortListService { if (typeof firstProperty !== typeof secondProperty) { // undefined/null items should always land at the end if (!firstProperty) { - return ascending ? 1 : -1; + return 1; } else if (!secondProperty) { - return ascending ? -1 : 1; + return -1; } else { throw new TypeError('sorting of items failed because of mismatched types'); } } else { + if ( + (firstProperty === null || firstProperty === undefined) && + (secondProperty === null || secondProperty === undefined) + ) { + return 1; + } switch (typeof firstProperty) { case 'boolean': if (firstProperty === false && secondProperty === true) {