(a, b)
| 1245 | |
| 1246 | // Comparison function based on selected column |
| 1247 | function compareRows(a, b) { |
| 1248 | let aValue, bValue; |
| 1249 | |
| 1250 | if (column === "name") { |
| 1251 | // For name sorting, use just the folder name (not full path) |
| 1252 | aValue = a.dataset.path.split("/").pop() || ""; |
| 1253 | bValue = b.dataset.path.split("/").pop() || ""; |
| 1254 | return currentSort.ascending |
| 1255 | ? aValue.localeCompare(bValue) |
| 1256 | : bValue.localeCompare(aValue); |
| 1257 | } else if (column === "date") { |
| 1258 | // Get timestamps, treat empty/missing as 0 (will sort to the end when ascending) |
| 1259 | aValue = parseInt(a.dataset.timestamp) || 0; |
| 1260 | bValue = parseInt(b.dataset.timestamp) || 0; |
| 1261 | |
| 1262 | // Put entries without timestamps at the end |
| 1263 | if (aValue === 0 && bValue === 0) return 0; |
| 1264 | if (aValue === 0) return 1; |
| 1265 | if (bValue === 0) return -1; |
| 1266 | |
| 1267 | return currentSort.ascending ? aValue - bValue : bValue - aValue; |
| 1268 | } |
| 1269 | |
| 1270 | return 0; |
| 1271 | } |
| 1272 | |
| 1273 | // Sort all rows |
| 1274 | rows.sort(compareRows); |
nothing calls this directly
no outgoing calls
no test coverage detected