From 74517e5c03ad8f398391ad8dce94ef03b9109c47 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sat, 8 Dec 2018 16:21:18 +0300 Subject: [PATCH] tweaking tag sorting in cloud... Signed-off-by: Alex A. Naanou --- ui (gen4)/features/tags.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/ui (gen4)/features/tags.js b/ui (gen4)/features/tags.js index 8b13e295..62f403e9 100755 --- a/ui (gen4)/features/tags.js +++ b/ui (gen4)/features/tags.js @@ -270,33 +270,33 @@ var TagUIActions = actions.Actions({ t, i, (that.data.tags.values(t) || []).length, - tags.indexOf(t) >= 0] }) + tags.indexOf(t) >= 0 ] }) // XXX add ability to sort by popularity, both local // (selected tags) and global... .run(function(){ return opts.sortTagsBy == 'name' ? this - // count... + // usage and count... : this.sort(function(a, b){ var ac = a[2] var bc = b[2] - return ac != null && bc != null ? - bc - ac + return ( // keep set tags before unset... - // XXX these do not seem to work... - : a[3] && !b[3] ? - 1 + a[3] && !b[3] ? + -1 : !a[3] && b[3] ? - -1 - // keep used tags before unused... - : ac == null || (!a[3] && b[3]) ? 1 - : bc == null || (a[3] && !b[3]) ? + // sort by usage count... + : ac != null && bc != null ? + bc - ac + // keep used tags before unused... + : ac == null ? + 1 + : bc == null ? -1 - // sort by position... - : a[0] - b[0] - }) }) + // keep position... + : a[0] - b[0] ) }) }) .map(function(tag){ // normalize... var count = tag[2]