add button to determine sort order and local storage to save preferences
diff --git a/ui-modules/app-inspector/app/components/entity-tree/entity-tree.directive.js b/ui-modules/app-inspector/app/components/entity-tree/entity-tree.directive.js
index ed11b0f..5a8017f 100644
--- a/ui-modules/app-inspector/app/components/entity-tree/entity-tree.directive.js
+++ b/ui-modules/app-inspector/app/components/entity-tree/entity-tree.directive.js
@@ -43,6 +43,9 @@
     return {
         restrict: 'E',
         template: entityTreeTemplate,
+        scope: {
+           sortReverse: '=',
+        },
         controller: ['$scope', '$state', 'applicationApi', 'entityApi', 'iconService', 'brWebNotifications', controller],
         controllerAs: 'vm'
     };
diff --git a/ui-modules/app-inspector/app/components/entity-tree/entity-tree.html b/ui-modules/app-inspector/app/components/entity-tree/entity-tree.html
index a26aada..ea33ed6 100644
--- a/ui-modules/app-inspector/app/components/entity-tree/entity-tree.html
+++ b/ui-modules/app-inspector/app/components/entity-tree/entity-tree.html
@@ -16,7 +16,7 @@
   specific language governing permissions and limitations
   under the License.
 -->
-<entity-node ng-repeat="application in vm.applications | orderBy: '-startTimeUtc' track by application.id" entity="application" application-id="application.id"></entity-node>
+<entity-node ng-repeat="application in vm.applications | orderBy: sortReverse? '-startTimeUtc': 'startTimeUtc' track by application.id" entity="application" application-id="application.id"></entity-node>
 <p class="expand-tree-message text-center" ng-if="vm.applications.length > 0"><small><kbd>shift</kbd> + <kbd>{{navigator.appVersion.indexOf("Mac") !== -1 ? '⌘' : '⊞'}}</kbd> + click to expand all children</small></p>
 <div class="empty-tree text-muted text-center" ng-if="vm.applications.length === 0">
     <hr />
diff --git a/ui-modules/app-inspector/app/views/main/main.controller.js b/ui-modules/app-inspector/app/views/main/main.controller.js
index 07280f8..c691a10 100644
--- a/ui-modules/app-inspector/app/views/main/main.controller.js
+++ b/ui-modules/app-inspector/app/views/main/main.controller.js
@@ -27,11 +27,16 @@
     controllerAs: 'ctrl'
 };
 
+const savedSortReverse = 'app-inspector-sort-reverse';
+
 export function mainController($scope, $q, brWebNotifications) {
     $scope.$emit(HIDE_INTERSTITIAL_SPINNER_EVENT);
 
     let ctrl = this;
 
+    ctrl.sortReverse = localStorage && localStorage.getItem(savedSortReverse) !== null ?
+        JSON.parse(localStorage.getItem(savedSortReverse)) :
+        true;
     brWebNotifications.supported.then(() => {
         ctrl.isNotificationsSupported = true;
     }).catch(() => {
@@ -48,6 +53,17 @@
         ctrl.isNotificationsBlocked = permission === 'denied';
     });
 
+    ctrl.toggleSortOrder = () => {
+        ctrl.sortReverse = !ctrl.sortReverse;
+        if (localStorage) {
+            try {
+                localStorage.setItem(savedSortReverse, JSON.stringify(ctrl.sortReverse));
+            } catch (ex) {
+                $log.error('Cannot save app sort preferences: ' + ex.message);
+            }
+        }
+    }
+
     ctrl.toggleNotifications = () => {
         brWebNotifications.isEnabled().then(() => {
             return brWebNotifications.setEnable(false);
diff --git a/ui-modules/app-inspector/app/views/main/main.template.html b/ui-modules/app-inspector/app/views/main/main.template.html
index 0911647..8721985 100644
--- a/ui-modules/app-inspector/app/views/main/main.template.html
+++ b/ui-modules/app-inspector/app/views/main/main.template.html
@@ -24,6 +24,11 @@
                     <div class="entity-tree-header">
                         <h2 class="entity-tree-title">Applications</h2>
 
+                        <button class="entity-sort-action" >
+                            <div class="entity-sort-action-toggle" ng-click="ctrl.toggleSortOrder($event)" >
+                                <span class="glyphicon" ng-class="ctrl.sortReverse ? 'fa fa-sort-amount-desc' : 'fa fa-sort-amount-asc'"></span>
+                            </div>
+                        </button>
                         <button class="btn btn-link entity-tree-action"
                                 ng-class="{'btn-sm': !ctrl.isNotificationsBlocked, 'btn-xs': ctrl.isNotificationsBlocked}"
                                 ng-if="ctrl.isNotificationsSupported"
@@ -44,7 +49,7 @@
                         </a>
                     </div>
 
-                    <entity-tree></entity-tree>
+                    <entity-tree sort-reverse="ctrl.sortReverse"></entity-tree>
                 </br-card-content>
             </br-card>