User:Incnis Mrsi/Dictsort categories.js

/* Sorting categories alphabetically. The script is partially based on User:Anomie/previewtemplatelastmod.js function DictsortCategories { var node=document.getElementById('mw-normal-catlinks'); //       alert('mw-normal-catlinks.innerHTML = ' + node.innerHTML); if(!node) return; var li = Array.prototype.slice.call(node.getElementsByTagName('li')); //       alert('li.length = ' + li.length); if(li.length<=1) return; li.sort( function(a,b){ return (a.firstChild.titleb.firstChild.title)?-1:0; }); var cur=li[0].parentNode.firstChild; for(var j=li.length-1; j>=0; j--){ if(li[j]===cur){ cur=cur.nextSibling; } else { cur.parentNode.insertBefore(li[j],cur); }       }        node.firstChild.href = "/wiki/User:Incnis_Mrsi/Dictsort_categories"; node.firstChild.title = "(sorted alphabetically)"; node.firstChild.innerHTML += '\u25C4'; //       alert(li.length + ' categories sorted'); }; addOnloadHook(DictsortCategories);

/*