Stabilize WI sorting order

This commit is contained in:
Cohee 2023-10-06 01:18:50 +03:00
parent 2797b4bd89
commit 27ce0b5eb7

View File

@ -256,7 +256,7 @@ function sortEntries(data) {
return (aValue - bValue || b.order - a.order);
});
} else {
data.sort((a, b) => {
const primarySort = (a, b) => {
const aValue = a[sortField];
const bValue = b[sortField];
@ -273,6 +273,24 @@ function sortEntries(data) {
// Sort numbers
return orderSign * (Number(aValue) - Number(bValue));
};
const secondarySort = (a, b) => b.order - a.order;
const tertiarySort = (a, b) => a.uid - b.uid;
data.sort((a, b) => {
const primary = primarySort(a, b);
if (primary !== 0) {
return primary;
}
const secondary = secondarySort(a, b);
if (secondary !== 0) {
return secondary;
}
return tertiarySort(a, b);
});
}