Files
Crm-Frontend/src/utils/lexorank/sort.ts

11 lines
409 B
TypeScript

import { compareByLexorankWithKey } from "@/utils/lexorank/compare";
import { LexorankSortable } from "@/utils/lexorank/types";
export function sortByLexorank<T extends LexorankSortable>(items: T[]): T[] {
return sortByLexorankWithKey(items, "lexorank");
}
export function sortByLexorankWithKey<T>(items: T[], key: keyof T): T[] {
return items.sort((a, b) => compareByLexorankWithKey(a, b, key));
}