luci-base: network.js: sort interface statuses by metric, then name
authorJo-Philipp Wich <jo@mein.io>
Mon, 1 Mar 2021 09:42:10 +0000 (10:42 +0100)
committerJo-Philipp Wich <jo@mein.io>
Mon, 1 Mar 2021 09:42:10 +0000 (10:42 +0100)
Fixes: #4693
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
modules/luci-base/htdocs/luci-static/resources/network.js

index 1f749c593cacffeddd02de6f4c2f64bc77ffa65e..1e24915f979ff700a7961cfef1f86c0227b15344 100644 (file)
@@ -1453,6 +1453,18 @@ Network = baseclass.extend(/** @lends LuCI.network.prototype */ {
                                }
                        }
 
+                       rv.sort(function(a, b) {
+                               if (a.metric != b.metric)
+                                       return (a.metric - b.metric);
+
+                               if (a.interface < b.interface)
+                                       return -1;
+                               else if (a.interface > b.interface)
+                                       return 1;
+
+                               return 0;
+                       });
+
                        return rv;
                }, this));
        },