mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-12 08:16:16 -07:00
parent
8e39ac7efd
commit
b67da4bebe
1 changed files with 10 additions and 12 deletions
|
@ -490,20 +490,18 @@ window.addEvent('load', function() {
|
||||||
Object.each(category_list, function(category) {
|
Object.each(category_list, function(category) {
|
||||||
sortedCategories.push(category.name);
|
sortedCategories.push(category.name);
|
||||||
});
|
});
|
||||||
sortedCategories.sort(function(category1, category2) {
|
sortedCategories.sort((leftCategory, rightCategory) => {
|
||||||
for (let i = 0; i < Math.min(category1.length, category2.length); ++i) {
|
const leftSegments = leftCategory.split('/');
|
||||||
if (category1[i] === "/" && category2[i] !== "/") {
|
const rightSegments = rightCategory.split('/');
|
||||||
return -1;
|
|
||||||
}
|
for (let i = 0, iMax = Math.min(leftSegments.length, rightSegments.length); i < iMax; ++i) {
|
||||||
else if (category1[i] !== "/" && category2[i] === "/") {
|
const compareResult = window.qBittorrent.Misc.naturalSortCollator.compare(
|
||||||
return 1;
|
leftSegments[i], rightSegments[i]);
|
||||||
}
|
if (compareResult !== 0)
|
||||||
else if (category1[i] !== category2[i]) {
|
return compareResult;
|
||||||
return category1[i].localeCompare(category2[i]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return category1.length - category2.length;
|
return leftSegments.length - rightSegments.length;
|
||||||
});
|
});
|
||||||
|
|
||||||
for (let i = 0; i < sortedCategories.length; ++i) {
|
for (let i = 0; i < sortedCategories.length; ++i) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue