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));
}
