ONOS-2849: Pre-populate sort so active apps are at the top of the list.

Change-Id: Id21025d5130ee156225fcd367d9ff0680781a930
diff --git a/web/gui/src/main/webapp/app/fw/widget/tableBuilder.js b/web/gui/src/main/webapp/app/fw/widget/tableBuilder.js
index 59a8570..f4e0783 100644
--- a/web/gui/src/main/webapp/app/fw/widget/tableBuilder.js
+++ b/web/gui/src/main/webapp/app/fw/widget/tableBuilder.js
@@ -54,7 +54,7 @@
 
         o.scope.tableData = [];
         o.scope.changedData = [];
-        o.scope.sortParams = {};
+        o.scope.sortParams = o.sortParams || {};
         o.scope.autoRefresh = true;
         o.scope.autoRefreshTip = 'Toggle auto refresh';
 
@@ -149,7 +149,7 @@
             cancelTardy();
         });
 
-        sortCb();
+        sortCb(o.scope.sortParams);
         startRefresh();
     }
 
diff --git a/web/gui/src/main/webapp/app/view/app/app.js b/web/gui/src/main/webapp/app/view/app/app.js
index 3b27c38..f7b8bbf 100644
--- a/web/gui/src/main/webapp/app/view/app/app.js
+++ b/web/gui/src/main/webapp/app/view/app/app.js
@@ -68,7 +68,12 @@
             scope: $scope,
             tag: 'app',
             selCb: selCb,
-            respCb: refreshCtrls
+            respCb: refreshCtrls,
+            // pre-populate sort so active apps are at the top of the list
+            sortParams: {
+                sortCol: 'state',
+                sortDir: 'desc'
+            }
         });
 
         // TODO: reexamine where keybindings should be - directive or controller?