[ui] sorting improvements
parent
9639bec677
commit
604292d56d
|
@ -5,6 +5,13 @@ export type SortKeys = { [key: string]: string[] };
|
|||
export function sortByValue(entries: UpEntry[], sortKeys: SortKeys): void {
|
||||
entries
|
||||
.sort((aEntry, bEntry) => {
|
||||
return String(aEntry.value.c).length - String(bEntry.value.c).length;
|
||||
})
|
||||
.sort((aEntry, bEntry) => {
|
||||
if (aEntry.value.t === "Number" && bEntry.value.t === "Number") {
|
||||
return bEntry.value.c - aEntry.value.c;
|
||||
}
|
||||
|
||||
if (
|
||||
!sortKeys[aEntry.value.c]?.length ||
|
||||
!sortKeys[bEntry.value.c]?.length
|
||||
|
@ -20,7 +27,11 @@ export function sortByValue(entries: UpEntry[], sortKeys: SortKeys): void {
|
|||
) {
|
||||
return 1;
|
||||
} else {
|
||||
return String(aEntry.value.c).localeCompare(String(bEntry.value.c));
|
||||
return String(aEntry.value.c).localeCompare(
|
||||
String(bEntry.value.c),
|
||||
undefined,
|
||||
{ numeric: true, sensitivity: "base" }
|
||||
);
|
||||
}
|
||||
} else {
|
||||
return sortKeys[aEntry.value.c][0].localeCompare(
|
||||
|
@ -29,9 +40,6 @@ export function sortByValue(entries: UpEntry[], sortKeys: SortKeys): void {
|
|||
{ numeric: true, sensitivity: "base" }
|
||||
);
|
||||
}
|
||||
})
|
||||
.sort((aEntry, bEntry) => {
|
||||
return String(aEntry.value.c).length - String(bEntry.value.c).length;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -82,3 +90,14 @@ export function defaultEntitySort(
|
|||
sortByEntity(entries, sortKeys);
|
||||
return result;
|
||||
}
|
||||
|
||||
export function entityValueSort(
|
||||
entries: UpEntry[],
|
||||
sortKeys: SortKeys
|
||||
): UpEntry[] {
|
||||
const result = entries.concat();
|
||||
sortByEntity(entries, sortKeys);
|
||||
sortByAttribute(entries);
|
||||
sortByValue(entries, sortKeys);
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue