(sort)
| 142 | return comparePopular(a, b); |
| 143 | } |
| 144 | |
| 145 | function applySort(sort) { |
| 146 | activeSort = SORT_OPTIONS.has(sort) ? sort : "featured"; |
| 147 | |
| 148 | if (sortSelect) { |
| 149 | sortSelect.value = activeSort; |
| 150 | } |
| 151 | |
| 152 | loopRows.sort((a, b) => { |
| 153 | if (activeSort === "alphabetical") { |
| 154 | return rowTitle(a).localeCompare(rowTitle(b), undefined, { |
| 155 | sensitivity: "base", |
| 156 | }); |
| 157 | } |
| 158 | |
| 159 | if (activeSort === "popular") { |
| 160 | return comparePopular(a, b); |
| 161 | } |
| 162 | |
| 163 | if (activeSort === "newest") { |
| 164 | return compareNewest(a, b); |
| 165 | } |
| 166 | |
| 167 | return activeSort === "oldest" ? compareOldest(a, b) : compareFeatured(a, b); |
| 168 | }); |
| 169 | |
| 170 | if (loopTableBody) { |
| 171 | loopRows.forEach((row) => loopTableBody.append(row)); |
no test coverage detected