parent
133a848218
commit
55bf3123f9
|
@ -58,6 +58,8 @@
|
|||
}
|
||||
|
||||
// Sorting
|
||||
let sortedAttributes = entries;
|
||||
|
||||
let sortKeys: { [key: string]: string[] } = {};
|
||||
function addSortKeys(key: string, vals: string[]) {
|
||||
if (!sortKeys[key]) {
|
||||
|
@ -68,6 +70,69 @@
|
|||
sortKeys[key].push(val);
|
||||
}
|
||||
});
|
||||
|
||||
sortAttributes();
|
||||
}
|
||||
|
||||
function sortAttributes() {
|
||||
sortedAttributes = entries
|
||||
.concat()
|
||||
.sort((aEntry, bEntry) => {
|
||||
if (
|
||||
!Boolean(sortKeys[aEntry.value.c]?.length) ||
|
||||
!Boolean(sortKeys[bEntry.value.c]?.length)
|
||||
) {
|
||||
if (
|
||||
Boolean(sortKeys[aEntry.value.c]?.length) &&
|
||||
!Boolean(sortKeys[bEntry.value.c]?.length)
|
||||
) {
|
||||
return -1;
|
||||
} else if (
|
||||
!Boolean(sortKeys[aEntry.value.c]?.length) &&
|
||||
Boolean(sortKeys[bEntry.value.c]?.length)
|
||||
) {
|
||||
return 1;
|
||||
} else {
|
||||
return String(aEntry.value.c).localeCompare(String(bEntry.value.c));
|
||||
}
|
||||
} else {
|
||||
return sortKeys[aEntry.value.c][0].localeCompare(
|
||||
sortKeys[bEntry.value.c][0],
|
||||
undefined,
|
||||
{ numeric: true, sensitivity: "base" }
|
||||
);
|
||||
}
|
||||
})
|
||||
.sort((aEntry, bEntry) => {
|
||||
return String(aEntry.value.c).length - String(bEntry.value.c).length;
|
||||
})
|
||||
.sort((aEntry, bEntry) => {
|
||||
return aEntry.attribute.localeCompare(bEntry.attribute);
|
||||
})
|
||||
.sort((aEntry, bEntry) => {
|
||||
if (
|
||||
!Boolean(sortKeys[aEntry.entity]?.length) ||
|
||||
!Boolean(sortKeys[bEntry.entity]?.length)
|
||||
) {
|
||||
if (
|
||||
Boolean(sortKeys[aEntry.entity]?.length) &&
|
||||
!Boolean(sortKeys[bEntry.entity]?.length)
|
||||
) {
|
||||
return -1;
|
||||
} else if (
|
||||
!Boolean(sortKeys[aEntry.entity]?.length) &&
|
||||
Boolean(sortKeys[bEntry.entity]?.length)
|
||||
) {
|
||||
return 1;
|
||||
} else {
|
||||
return aEntry.entity.localeCompare(bEntry.entity);
|
||||
}
|
||||
} else {
|
||||
return sortKeys[aEntry.entity][0].localeCompare(
|
||||
sortKeys[bEntry.entity][0]
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
entries.forEach((entry) => {
|
||||
|
@ -80,65 +145,6 @@
|
|||
}
|
||||
});
|
||||
|
||||
$: sortedAttributes = entries
|
||||
.concat()
|
||||
.sort((aEntry, bEntry) => {
|
||||
if (
|
||||
!Boolean(sortKeys[aEntry.value.c]?.length) ||
|
||||
!Boolean(sortKeys[bEntry.value.c]?.length)
|
||||
) {
|
||||
if (
|
||||
Boolean(sortKeys[aEntry.value.c]?.length) &&
|
||||
!Boolean(sortKeys[bEntry.value.c]?.length)
|
||||
) {
|
||||
return -1;
|
||||
} else if (
|
||||
!Boolean(sortKeys[aEntry.value.c]?.length) &&
|
||||
Boolean(sortKeys[bEntry.value.c]?.length)
|
||||
) {
|
||||
return 1;
|
||||
} else {
|
||||
return String(aEntry.value.c).localeCompare(String(bEntry.value.c));
|
||||
}
|
||||
} else {
|
||||
return sortKeys[aEntry.value.c][0].localeCompare(
|
||||
sortKeys[bEntry.value.c][0],
|
||||
undefined,
|
||||
{ numeric: true, sensitivity: "base" }
|
||||
);
|
||||
}
|
||||
})
|
||||
.sort((aEntry, bEntry) => {
|
||||
return String(aEntry.value.c).length - String(bEntry.value.c).length;
|
||||
})
|
||||
.sort((aEntry, bEntry) => {
|
||||
return aEntry.attribute.localeCompare(bEntry.attribute);
|
||||
})
|
||||
.sort((aEntry, bEntry) => {
|
||||
if (
|
||||
!Boolean(sortKeys[aEntry.entity]?.length) ||
|
||||
!Boolean(sortKeys[bEntry.entity]?.length)
|
||||
) {
|
||||
if (
|
||||
Boolean(sortKeys[aEntry.entity]?.length) &&
|
||||
!Boolean(sortKeys[bEntry.entity]?.length)
|
||||
) {
|
||||
return -1;
|
||||
} else if (
|
||||
!Boolean(sortKeys[aEntry.entity]?.length) &&
|
||||
Boolean(sortKeys[bEntry.entity]?.length)
|
||||
) {
|
||||
return 1;
|
||||
} else {
|
||||
return aEntry.entity.localeCompare(bEntry.entity);
|
||||
}
|
||||
} else {
|
||||
return sortKeys[aEntry.entity][0].localeCompare(
|
||||
sortKeys[bEntry.entity][0]
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
// Navigation highlights
|
||||
const { index } = getContext("browse") as { index: Writable<number> };
|
||||
$: addresses = $params.addresses.split(",");
|
||||
|
|
Loading…
Reference in New Issue