More actions
No edit summary Tag: Reverted |
No edit summary Tag: Manual revert |
||
Line 2: | Line 2: | ||
// Sort categories alphabetically by the first character after the colon | // Sort categories alphabetically by the first character after the colon | ||
$(function() { | |||
var $categories = $('.mw-normal-catlinks ul li'); | |||
.mw-normal-catlinks ul { | $categories.sort(function(a, b) { | ||
var textA = $(a).text().toUpperCase(); | |||
var textB = $(b).text().toUpperCase(); | |||
var charA = textA.match(/:(.)/)[1]; | |||
} | var charB = textB.match(/:(.)/)[1]; | ||
return (charA < charB) ? -1 : (charA > charB) ? 1 : 0; | |||
.mw-normal-catlinks ul | }); | ||
$('.mw-normal-catlinks ul').empty().append($categories); | |||
}); | |||
Revision as of 20:43, 17 March 2024
/* Any JavaScript here will be loaded for all users on every page load. */ // Sort categories alphabetically by the first character after the colon $(function() { var $categories = $('.mw-normal-catlinks ul li'); $categories.sort(function(a, b) { var textA = $(a).text().toUpperCase(); var textB = $(b).text().toUpperCase(); var charA = textA.match(/:(.)/)[1]; var charB = textB.match(/:(.)/)[1]; return (charA < charB) ? -1 : (charA > charB) ? 1 : 0; }); $('.mw-normal-catlinks ul').empty().append($categories); });