From 2a1a399382d0fbfc01fefd29b3b040d01d968e15 Mon Sep 17 00:00:00 2001 From: Marc Foley Date: Wed, 28 May 2025 16:21:52 +0100 Subject: [PATCH] fix trending and popularity sort --- .ci/tags.html | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/.ci/tags.html b/.ci/tags.html index c48fac97f..f94dc9384 100644 --- a/.ci/tags.html +++ b/.ci/tags.html @@ -293,7 +293,7 @@ function axesCombos(axes) { return this.family.toStyle(); }, familyDisplayName() { - return this.family.displayName; + return `${this.family.displayName}`; }, familyTag() { return this.family.tag @@ -381,12 +381,27 @@ function axesCombos(axes) { sortFunc = function(a, b) {return a.displayName.localeCompare(b.displayName)} } else if (["Popularity", "Trending"].includes(this.sortMethod)) { sortFunc = function(a, b) { - const aFamilyData = _this.familyData[b.displayName] - const bFamilyData = _this.familyData[a.displayName] - if (aFamilyData === undefined || bFamilyData === undefined) { + let aVal, bVal; + const aFamilyData = _this.familyData[a.displayName] + const bFamilyData = _this.familyData[b.displayName] + if (aFamilyData === undefined) { + aVal = Number.MAX_SAFE_INTEGER; + } else { + aVal = aFamilyData[_this.sortMethod.toLowerCase()]; + } + if (bFamilyData === undefined) { + bVal = Number.MAX_SAFE_INTEGER; + } else { + bVal = bFamilyData[_this.sortMethod.toLowerCase()]; + } + + if (aVal < bVal) { + return -1; + } else if (aVal > bVal) { return 1; + } else { + return 0; } - return bFamilyData[_this.sortMethod.toLowerCase()] - aFamilyData[_this.sortMethod.toLowerCase()]; } } let filtered = this.tags; @@ -398,6 +413,7 @@ function axesCombos(axes) { } filtered.sort(sortFunc); + if (this.reverseTags) { filtered.reverse(); } -- 2.47.2