Update:Author number of books sort fallsback to sort on name when num books is the same

This commit is contained in:
advplyr 2024-08-31 14:59:42 -05:00
parent 98cd19d440
commit 064679c057

View File

@ -61,6 +61,8 @@ export default {
const bDesc = this.authorSortDesc ? -1 : 1
return this.authors.sort((a, b) => {
if (typeof a[sortProp] === 'number' && typeof b[sortProp] === 'number') {
// Fallback to name sort if equal
if (a[sortProp] === b[sortProp]) return a.name.localeCompare(b.name, undefined, { sensitivity: 'base' }) * bDesc
return a[sortProp] > b[sortProp] ? bDesc : -bDesc
}
return a[sortProp]?.localeCompare(b[sortProp], undefined, { sensitivity: 'base' }) * bDesc