Merge pull request #4133 from MaximilianKrambach/sortEmpties

move empty/undefined sortings always to the alphabet's end
This commit is contained in:
Emanuel Schütze 2019-01-19 11:55:10 +01:00 committed by GitHub
commit 2d40072f44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -209,13 +209,19 @@ export abstract class SortListService<V extends BaseViewModel> {
if (typeof firstProperty !== typeof secondProperty) { if (typeof firstProperty !== typeof secondProperty) {
// undefined/null items should always land at the end // undefined/null items should always land at the end
if (!firstProperty) { if (!firstProperty) {
return ascending ? 1 : -1; return 1;
} else if (!secondProperty) { } else if (!secondProperty) {
return ascending ? -1 : 1; return -1;
} else { } else {
throw new TypeError('sorting of items failed because of mismatched types'); throw new TypeError('sorting of items failed because of mismatched types');
} }
} else { } else {
if (
(firstProperty === null || firstProperty === undefined) &&
(secondProperty === null || secondProperty === undefined)
) {
return 1;
}
switch (typeof firstProperty) { switch (typeof firstProperty) {
case 'boolean': case 'boolean':
if (firstProperty === false && secondProperty === true) { if (firstProperty === false && secondProperty === true) {