diff --git a/History.md b/History.md
index 8a1dd2a7..eec8b027 100644
--- a/History.md
+++ b/History.md
@@ -1,7 +1,8 @@
2.0.20 / 2024-??-??
==================
+ * Fix sort by name implementation (https://github.com/tntim96/JSCover/issues/328)
* Upgrade closure-compiler v20231112 to v20240317, gson 2.10.1 to 2.11.0
- * Internal: HtmlUnit 3.9.0 to 4.1.0, Mockito 5.8.0 to 5.12.0, JaCoCo 0.8.11 to 0.8.12, Rhino 1.7.14 to 1.7.15, Maven Resolver Ant Tasks 1.2.1-SNAPSHOT to 1.5.1
+ * Internal: HtmlUnit 3.9.0 to 4.4.0, Mockito 5.8.0 to 5.12.0, JaCoCo 0.8.11 to 0.8.12, Rhino 1.7.14 to 1.7.15, Maven Resolver Ant Tasks 1.2.1-SNAPSHOT to 1.5.1
2.0.19 / 2024-01-02
==================
diff --git a/JSCover.iml b/JSCover.iml
index 060f24c4..3a38ac6f 100644
--- a/JSCover.iml
+++ b/JSCover.iml
@@ -41,22 +41,22 @@
-
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
-
+
+
+
diff --git a/JSCover.ipr b/JSCover.ipr
index e9dbf1c0..70fd7400 100644
--- a/JSCover.ipr
+++ b/JSCover.ipr
@@ -683,6 +683,11 @@
+
+
+
+
+
@@ -740,16 +745,16 @@
-
-
+
+
-
+
-
+
-
+
@@ -764,28 +769,28 @@
-
-
+
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
@@ -824,16 +829,16 @@
-
-
+
+
-
+
-
+
-
+
@@ -920,88 +925,88 @@
-
-
+
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
diff --git a/pom.xml b/pom.xml
index baf231f6..21ed494a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -83,7 +83,7 @@
org.htmlunit
htmlunit
- 4.1.0
+ 4.4.0
test
diff --git a/src/main/resources/jscoverage.js b/src/main/resources/jscoverage.js
index 6e9aa2af..eed30560 100644
--- a/src/main/resources/jscoverage.js
+++ b/src/main/resources/jscoverage.js
@@ -834,18 +834,18 @@ function getFilesSortedByCoverage(filesIn) {
files[i].fnPc = getSafeVal(parseInt(tbody.children[i].children[12].children[1].innerHTML, 10));
}
- if (sortOrder%3===1) {
- if (sortColumn == 'Name')
- files.sort(function(file1,file2) {return file1.file>=file2.file});
- else
- files.sort(function(file1,file2) {return file1[sortColumn]-file2[sortColumn]});
- } else if (sortOrder%3===2) {
- if (sortColumn == 'Name')
- files.sort(function(file1,file2) {return file2.file>=file1.file});
- else
- files.sort(function(file1,file2) {return file2[sortColumn]-file1[sortColumn]});
+ if (sortOrder%3===0) {
+ return filesIn.sort();
} else {
- return filesIn.sort();
+ var order = 1;
+ var property = sortColumn;
+ if (sortColumn == 'Name') property = 'file';
+ if (sortOrder%3===2) order = -1;
+ files.sort(function (file1, file2) {
+ if(file1[property] < file2[property]) { return -1 * order; }
+ if(file1[property] > file2[property]) { return 1 * order; }
+ return 0;
+ });
}
var result = [];
for (var i=0;i