test alphabetical sorting again

This commit is contained in:
MrOtherGuy 2020-06-06 13:43:26 +03:00
parent 11fcf00269
commit 1e56cd34ad
2 changed files with 7 additions and 4 deletions

View file

@ -15,6 +15,7 @@ a:visited{ color: rgb(150,100,200) }
a:hover{ color: rgb(200,150,100) } a:hover{ color: rgb(200,150,100) }
pre:empty{ display: none } pre:empty{ display: none }
.category{ padding: 0.2em 1em; cursor: pointer } .category{ padding: 0.2em 1em; cursor: pointer }
.category::after{ content: " (" attr(data-value) ")"}
.currentCategory, .currentCategory,
.category:hover{ background-color: grey } .category:hover{ background-color: grey }

View file

@ -106,7 +106,8 @@ function createCategories(){
link.title = "See on Github"; link.title = "See on Github";
link.target = "_blank"; link.target = "_blank";
}else{ }else{
node.textContent = name; node.textContent = name.name;
node.setAttribute("data-value",name.value);
} }
return node; return node;
@ -140,12 +141,13 @@ function createCategories(){
} }
} }
let map = ret.map((a,i)=>({name:a,value:ns[i]})) let map = ret.map((a,i)=>({name:a,value:ns[i]}))
return map
return map.sort((a,b)=>(a.value > b.value?-1:a.value < b.value ? 1:0)) //return map.sort((a,b)=>(a.value > b.value?-1:a.value < b.value ? 1:0))
})(); })();
for(let cat of CAT_NAMES){ for(let cat of CAT_NAMES){
CAT_PARENT.appendChild(createCategory(cat.name)) // CAT_PARENT.appendChild(createCategory(cat.name))
CAT_PARENT.appendChild(createNode(cat,"category"))
} }
} }