From be7b6e34510178bb129f932e7990b3dfcd6ddeb1 Mon Sep 17 00:00:00 2001
From: Gary O'Neall <gary@sourceauditor.com>
Date: Thu, 20 Dec 2018 11:07:00 -0800
Subject: [PATCH 1/2] Fix sorting of licenses in the license TOC HTML page

Signed-off-by: Gary O'Neall <gary@sourceauditor.com>
---
 src/org/spdx/htmltemplates/LicenseTOCHTMLFile.java | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/org/spdx/htmltemplates/LicenseTOCHTMLFile.java b/src/org/spdx/htmltemplates/LicenseTOCHTMLFile.java
index ebb8a33..ed7e8cf 100644
--- a/src/org/spdx/htmltemplates/LicenseTOCHTMLFile.java
+++ b/src/org/spdx/htmltemplates/LicenseTOCHTMLFile.java
@@ -20,6 +20,7 @@
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStreamWriter;
+import java.util.Comparator;
 import java.util.List;
 import java.util.Map;
 
@@ -304,6 +305,14 @@ public void writeToFile(File htmlFile) throws IOException, MustacheException {
 	private Map<String, Object> buildMustachMap() {
 		Map<String, Object> retval = Maps.newHashMap();
 		retval.put("version", generateVersionString(version, releaseDate));
+		this.listedLicenses.sort(new Comparator<ListedSpdxLicense>() {
+
+			@Override
+			public int compare(ListedSpdxLicense arg0, ListedSpdxLicense arg1) {
+				return arg0.getLicenseId().compareToIgnoreCase(arg1.getLicenseId());
+			}
+			
+		});
 		retval.put("listedLicenses", this.listedLicenses);
 		retval.put("deprecatedLicenses", this.deprecatedLicenses);
 		return retval;
@@ -320,6 +329,4 @@ public void addDeprecatedLicense(SpdxListedLicense deprecatedLicense,
 				deprecatedLicense.getDeprecatedVersion()));
 		currentRefNumber++;
 	}
-	
-
 }

From d9616615f2a6959cc9fa48d007512cab79c2f5d3 Mon Sep 17 00:00:00 2001
From: Gary O'Neall <gary@sourceauditor.com>
Date: Thu, 20 Dec 2018 11:22:23 -0800
Subject: [PATCH 2/2] Sort the Exception TOC HTML page

Signed-off-by: Gary O'Neall <gary@sourceauditor.com>
---
 src/org/spdx/htmltemplates/ExceptionHtmlToc.java | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/org/spdx/htmltemplates/ExceptionHtmlToc.java b/src/org/spdx/htmltemplates/ExceptionHtmlToc.java
index 50937a7..ea42001 100644
--- a/src/org/spdx/htmltemplates/ExceptionHtmlToc.java
+++ b/src/org/spdx/htmltemplates/ExceptionHtmlToc.java
@@ -20,6 +20,7 @@
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStreamWriter;
+import java.util.Comparator;
 import java.util.List;
 import java.util.Map;
 
@@ -244,6 +245,14 @@ public void writeToFile(File exceptionTocFile, String version) throws MustacheEx
 
 		Map<String, Object> mustacheMap = Maps.newHashMap();
 		mustacheMap.put("version", StringEscapeUtils.escapeHtml4(version));
+		exceptions.sort(new Comparator<ExceptionRow>() {
+
+			@Override
+			public int compare(ExceptionRow arg0, ExceptionRow arg1) {
+				return arg0.getLicenseExceptionId().compareTo(arg1.getLicenseExceptionId());
+			}
+			
+		});
 		mustacheMap.put("listedExceptions", exceptions);
 		mustacheMap.put("deprecatedExceptions", deprecatedExceptions);
 		FileOutputStream stream = null;