diff --git a/js/mdtablesort.js b/js/mdtablesort.js index dd226eba..770c2963 100644 --- a/js/mdtablesort.js +++ b/js/mdtablesort.js @@ -130,6 +130,69 @@ function injectSortStyles() { document.head.appendChild(style); } +// Parse numeric values optionally containing commas and units (e.g. 1,024, 10k, 5 MB/s). +function parseNumberWithUnits(value) { + if (value === null || value === undefined) return null; + + // Remove thousands separators and normalize spacing + const cleaned = String(value).replace(/,/g, '').trim(); + if (!cleaned) return null; + + const match = cleaned.match(/^(-?\d+(?:\.\d+)?)(?:\s*([a-zA-Z]+(?:\/s)?|%))?$/); + if (!match) return null; + + const numberPart = parseFloat(match[1]); + if (isNaN(numberPart)) return null; + + const unit = (match[2] || '').toLowerCase(); + + const unitMultipliers = { + '': 1, + '%': 1, + 'k': 1e3, + 'kb': 1024, + 'kib': 1024, + 'kbyte': 1024, + 'kbytes': 1024, + 'kbit': 1e3, + 'kbit/s': 1e3, + 'kb/s': 1e3, + 'kbps': 1e3, + 'm': 1e6, + 'mb': 1024 * 1024, + 'mib': 1024 * 1024, + 'mbyte': 1024 * 1024, + 'mbytes': 1024 * 1024, + 'mbit': 1e6, + 'mbit/s': 1e6, + 'mb/s': 1e6, + 'mbps': 1e6, + 'g': 1e9, + 'gb': 1024 * 1024 * 1024, + 'gib': 1024 * 1024 * 1024, + 'gbyte': 1024 * 1024 * 1024, + 'gbytes': 1024 * 1024 * 1024, + 'gbit': 1e9, + 'gbit/s': 1e9, + 'gb/s': 1e9, + 'gbps': 1e9, + 't': 1e12, + 'tb': 1024 * 1024 * 1024 * 1024, + 'tib': 1024 * 1024 * 1024 * 1024, + 'tbyte': 1024 * 1024 * 1024 * 1024, + 'tbytes': 1024 * 1024 * 1024 * 1024, + 'tbit': 1e12, + 'tbit/s': 1e12, + 'tb/s': 1e12, + 'tbps': 1e12 + }; + + const multiplier = unitMultipliers[unit]; + if (multiplier === undefined) return null; + + return numberPart * multiplier; +} + // Add helper function to support "yyyy-MM-dd HH:mm:ss" format. function parseDate(str) { // If the string contains a space but no 'T', replace the first space with 'T' @@ -219,6 +282,15 @@ function sortTable(table) { continue; } + // Attempt parsing numbers with commas or units before falling back to strings + const parsedA = parseNumberWithUnits(valA); + const parsedB = parseNumberWithUnits(valB); + if (parsedA !== null && parsedB !== null) { + if (parsedA < parsedB) return crit.direction === 'asc' ? -1 : 1; + if (parsedA > parsedB) return crit.direction === 'asc' ? 1 : -1; + continue; + } + // Fallback to string comparison if (valA < valB) return crit.direction === 'asc' ? -1 : 1; if (valA > valB) return crit.direction === 'asc' ? 1 : -1; diff --git a/lib/jetty-compression-common-12.1.4.jar b/lib/jetty-compression-common-12.1.4.jar deleted file mode 100644 index 5af89320..00000000 Binary files a/lib/jetty-compression-common-12.1.4.jar and /dev/null differ diff --git a/lib/jetty-compression-common-12.1.5.jar b/lib/jetty-compression-common-12.1.5.jar new file mode 100644 index 00000000..88853e8c Binary files /dev/null and b/lib/jetty-compression-common-12.1.5.jar differ diff --git a/lib/jetty-websocket-core-common-12.1.4.jar b/lib/jetty-websocket-core-common-12.1.5.jar similarity index 86% rename from lib/jetty-websocket-core-common-12.1.4.jar rename to lib/jetty-websocket-core-common-12.1.5.jar index 3823334c..82399631 100644 Binary files a/lib/jetty-websocket-core-common-12.1.4.jar and b/lib/jetty-websocket-core-common-12.1.5.jar differ diff --git a/lib/jetty-websocket-jetty-client-12.1.4.jar b/lib/jetty-websocket-jetty-client-12.1.5.jar similarity index 79% rename from lib/jetty-websocket-jetty-client-12.1.4.jar rename to lib/jetty-websocket-jetty-client-12.1.5.jar index e4af3382..2f45cdf0 100644 Binary files a/lib/jetty-websocket-jetty-client-12.1.4.jar and b/lib/jetty-websocket-jetty-client-12.1.5.jar differ diff --git a/lib/jetty-websocket-jetty-common-12.1.4.jar b/lib/jetty-websocket-jetty-common-12.1.5.jar similarity index 82% rename from lib/jetty-websocket-jetty-common-12.1.4.jar rename to lib/jetty-websocket-jetty-common-12.1.5.jar index 98c6af2d..5cb0c1ed 100644 Binary files a/lib/jetty-websocket-jetty-common-12.1.4.jar and b/lib/jetty-websocket-jetty-common-12.1.5.jar differ diff --git a/pom.xml b/pom.xml index ffb6a377..3dc82354 100644 --- a/pom.xml +++ b/pom.xml @@ -250,12 +250,12 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma org.eclipse.jetty.compression jetty-compression-common - 12.1.4 + 12.1.5 org.eclipse.jetty.websocket jetty-websocket-jetty-common - 12.1.4 + 12.1.5 org.eclipse.jetty.websocket @@ -265,7 +265,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma org.eclipse.jetty.websocket jetty-websocket-jetty-client - 12.1.4 + 12.1.5 org.eclipse.jetty.websocket @@ -275,7 +275,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma org.eclipse.jetty.websocket jetty-websocket-core-common - 12.1.4 + 12.1.5 jline