UNPKG

diginext-utils

Version:
22 lines 652 B
/** * Sorts an array of objects by a numeric property in ascending order. * Creates a new sorted array without modifying the original. * * @template T - The type of elements in the array * @param array - The array to sort * @param key - The property key to sort by * @returns A new sorted array * * @example * ```ts * const items = [ * { value: 30 }, * { value: 10 }, * { value: 20 } * ]; * sortByNumber(items, 'value'); * // [{ value: 10 }, { value: 20 }, { value: 30 }] * ``` */ export declare function sortByNumber<T extends Record<string, unknown>>(array: T[], key: keyof T): T[]; //# sourceMappingURL=sortByNumber.d.ts.map