WebUI: Fix incorrect subcategory sorting

PR #19833.
Closes #19756.
This commit is contained in:
Bartu Özen 2023-11-02 11:35:42 +03:00 committed by Vladimir Golovnev (Glassez)
parent 54dffa1051
commit 837d39dac7
No known key found for this signature in database
GPG key ID: 52A2C7DEE2DFA6F7

View file

@ -488,7 +488,21 @@ window.addEvent('load', function() {
Object.each(category_list, function(category) {
sortedCategories.push(category.name);
});
sortedCategories.sort();
sortedCategories.sort(function(category1, category2) {
for (let i = 0; i < Math.min(category1.length, category2.length); ++i) {
if (category1[i] === "/" && category2[i] !== "/") {
return -1;
}
else if (category1[i] !== "/" && category2[i] === "/") {
return 1;
}
else if (category1[i] !== category2[i]) {
return category1[i].localeCompare(category2[i]);
}
}
return category1.length - category2.length;
});
for (let i = 0; i < sortedCategories.length; ++i) {
const categoryName = sortedCategories[i];