User:Acagastya/sortCats.js

$(function sortCategories { const normalCatLinks = document.getElementById('mw-normal-catlinks');  if(!normalCatLinks)  return;  const li = normalCatLinks.lastElementChild.children;  const list = [...li];  list.sort(function sortList(a, b) { if (a.innerText > b.innerText) return 1; if (a.innerText < b.innerText) return -1; return 0; }); const liCopy = [...li];  liCopy.forEach(child => child.remove);  list.forEach((li) => normalCatLinks.lastElementChild.appendChild(li)); });