UNPKG

diginext-utils

Version:
22 lines 674 B
/** * Sorts an array of objects by a string 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 users = [ * { name: 'Charlie' }, * { name: 'Alice' }, * { name: 'Bob' } * ]; * sortByString(users, 'name'); * // [{ name: 'Alice' }, { name: 'Bob' }, { name: 'Charlie' }] * ``` */ export declare function sortByString<T extends Record<string, unknown>>(array: T[], key: keyof T): T[]; //# sourceMappingURL=sortByString.d.ts.map