SOLR-16466: Admin UI - Make it optional to sort list of commandline args (#2246)

diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 281a1df..bdb44b6 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -97,6 +97,8 @@
 
 * SOLR-16403: A new cluster singleton plugin to automatically remove inactive shards. (Paul McArthur, David Smiley)
 
+* SOLR-16466: Admin UI - Make it optional to sort list of commandline args (Shawn Heisey, Vincenzo D'Amore via Christine Poerschke)
+
 Improvements
 ---------------------
 * SOLR-17119: When registering or updating a ConfigurablePlugin through the `/cluster/plugin` API,
diff --git a/solr/webapp/web/css/angular/index.css b/solr/webapp/web/css/angular/index.css
index de6ba0a..2f4c539 100644
--- a/solr/webapp/web/css/angular/index.css
+++ b/solr/webapp/web/css/angular/index.css
@@ -168,6 +168,21 @@
 #content #index #jvm .processors dt span { background-image: url( ../../img/ico/processor.png ); }
 #content #index #jvm .command_line_args dt span { background-image: url( ../../img/ico/terminal.png ); }
 
+#content #index #jvm #sort-command-line a
+{
+  background-image: url( ../../img/ico/ui-check-box-uncheck.png );
+  background-position: 0 50%;
+  color: #4D4D4D;
+  display: block;
+  padding-left: 21px;
+}
+
+#content #index #jvm #sort-command-line a.on
+{
+  background-image: url( ../../img/ico/ui-check-box.png );
+  color: #333;
+}
+
 #content #index #system h2 { background-image: url( ../../img/ico/system-monitor.png ); }
 
 #content #index #system
@@ -219,3 +234,4 @@
 
 #content #index #security h2 { background-image: url( ../../img/ico/prohibition.png ); }
 #content #index #security div { text-align: right; }
+
diff --git a/solr/webapp/web/js/angular/controllers/index.js b/solr/webapp/web/js/angular/controllers/index.js
index c744ef4..20a89ed 100644
--- a/solr/webapp/web/js/angular/controllers/index.js
+++ b/solr/webapp/web/js/angular/controllers/index.js
@@ -72,11 +72,26 @@
         data.system.totalSwapSpaceSize && data.system.freeSwapSpaceSize &&
         data.system.openFileDescriptorCount && data.system.maxFileDescriptorCount);
 
-      // command line args:
-      $scope.commandLineArgs = data.jvm.jmx.commandLineArgs.sort();
-    });
+      // save a copy of the original commandline args
+      $scope.commandLineArgsUnsorted = [...data.jvm.jmx.commandLineArgs];
+      // get commandline args latest orderby or defaults to "Unsorted"
+      $scope.commandLineOrderBy = sessionStorage.getItem("commandline.orderby") || "Unsorted";
+      $scope.showCommandLineArgs();
+      });
   };
-  $scope.reload();
+  $scope.toggleCommandLineOrder = function() {
+    $scope.commandLineOrderBy = ($scope.commandLineOrderBy=="Sorted") ? "Unsorted":"Sorted";
+    sessionStorage.setItem("commandline.orderby", $scope.commandLineOrderBy);
+    $scope.showCommandLineArgs();
+  }
+  $scope.showCommandLineArgs = function() {
+    if ($scope.commandLineOrderBy == "Sorted") {
+      $scope.commandLineArgs = [...$scope.commandLineArgsUnsorted].sort();
+    } else {
+      $scope.commandLineArgs = $scope.commandLineArgsUnsorted;
+    }
+  }
+$scope.reload();
 });
 
 var parse_memory_value = function( value ) {
diff --git a/solr/webapp/web/partials/index.html b/solr/webapp/web/partials/index.html
index 8e0c2b0..d96b822 100644
--- a/solr/webapp/web/partials/index.html
+++ b/solr/webapp/web/partials/index.html
@@ -214,7 +214,10 @@
                 <dt><span>Args</span></dt>
                 <dd ng-repeat="arg in commandLineArgs track by $index" ng-class="{'odd':$odd}">{{arg}}</dd>
               </dl></li>
-            
+              <li>
+                <div id="sort-command-line" ng-click="toggleCommandLineOrder()"><a ng-class="{on: commandLineOrderBy=='Sorted'}">Sort JVM Command line Args</a></div>
+              </li>
+
             </ul>
 
           </div>