luci-base: luci.js: fix sortedKeys() ordering
authorJo-Philipp Wich <jo@mein.io>
Tue, 9 Feb 2021 23:02:59 +0000 (00:02 +0100)
committerJo-Philipp Wich <jo@mein.io>
Tue, 9 Feb 2021 23:07:32 +0000 (00:07 +0100)
Chrome does not properly sort arrays when the sort function returns boolean
results, in contrast to Firefox which does.

Fix the issue by returning a numerical result instead.

Fixes: #4792
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
modules/luci-base/htdocs/luci-static/resources/luci.js

index 936630a79d312a79fd50d48465f1355893129816..23853e2cc89eb3363c0ff6b8163a5a08944722c9 100644 (file)
                        }).filter(function(e) {
                                return (e[1] != null);
                        }).sort(function(a, b) {
-                               return (a[1] > b[1]);
+                               if (a[1] < b[1])
+                                       return -1;
+                               else if (a[1] > b[1])
+                                       return 1;
+                               else
+                                       return 0;
                        }).map(function(e) {
                                return e[0];
                        });