tweaking tag sorting in cloud...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2018-12-08 16:21:18 +03:00
parent cbf420cbc4
commit 74517e5c03

View File

@ -276,27 +276,27 @@ var TagUIActions = actions.Actions({
.run(function(){ .run(function(){
return opts.sortTagsBy == 'name' ? return opts.sortTagsBy == 'name' ?
this this
// count... // usage and count...
: this.sort(function(a, b){ : this.sort(function(a, b){
var ac = a[2] var ac = a[2]
var bc = b[2] var bc = b[2]
return ac != null && bc != null ? return (
bc - ac
// keep set tags before unset... // keep set tags before unset...
// XXX these do not seem to work... a[3] && !b[3] ?
: a[3] && !b[3] ? -1
1
: !a[3] && b[3] ? : !a[3] && b[3] ?
-1
// keep used tags before unused...
: ac == null || (!a[3] && b[3]) ?
1 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 -1
// sort by position... // keep position...
: a[0] - b[0] : a[0] - b[0] ) }) })
}) })
.map(function(tag){ .map(function(tag){
// normalize... // normalize...
var count = tag[2] var count = tag[2]