/** * A highly optimized sorting function capable of efficiently handling billions of array elements * with support for complex objects and various data types. * * For very large arrays (millions of elements), this function automatically switches to * a chunked sorting algorithm that reduces memory pressure and improves cache efficiency. * You can control the chunk size with the `chunkSize` option. * * @template T - The type of array elements being sorted * @template V - The type of values being compared for sorting * * @param data - The array to be sorted * @param getItemValue - Function that extracts the comparable value from each array item * @param options - Configuration options to control the sorting behavior * * @returns The sorted array (either the original array modified in-place or a new array) * * @example * // Sort an array of objects by their 'name' property * const users = [ * { id: 101, name: "Alice", age: 28 }, * { id: 102, name: "bob", age: 34 }, * { id: 103, name: "Charlie", age: 21 } * ]; * * // Case-sensitive sort (default) * const sortedByName = sortBy(users, user => user.name); * // Result: [{ id: 101, name: "Alice", age: 28 }, { id: 103, name: "Charlie", age: 21 }, { id: 102, name: "bob", age: 34 }] * * // Case-insensitive sort * const sortedIgnoringCase = sortBy(users, user => user.name, { ignoreCase: true }); * // Result: [{ id: 101, name: "Alice", age: 28 }, { id: 102, name: "bob", age: 34 }, { id: 103, name: "Charlie", age: 21 }] * * @example * // Sort by date values in descending order (newest first) * const tasks = [ * { id: 1, title: "Task 1", deadline: new Date("2023-12-01") }, * { id: 2, title: "Task 2", deadline: new Date("2023-05-15") }, * { id: 3, title: "Task 3", deadline: new Date("2024-02-20") } * ]; * * const sortedByDeadline = sortBy(tasks, task => task.deadline, { direction: 'desc' }); * // Result: Tasks ordered with newest deadline first * * @example * // Create a new sorted array without modifying the original * const numbers = [5, 2, 9, 1, 5, 6]; * const sortedNumbers = sortBy(numbers, n => n, { inPlace: false }); * // numbers is still [5, 2, 9, 1, 5, 6] * // sortedNumbers is [1, 2, 5, 5, 6, 9] * * @example * // Handle very large datasets with custom chunk size for memory efficiency * const largeDataset = Array.from({ length: 1000000 }, () => Math.random()); * const sortedLarge = sortBy(largeDataset, n => n, { chunkSize: 25000 }); * // Uses chunked sorting to reduce memory pressure on large arrays */ export declare function sortBy(data: T[], getItemValue: (item: T) => V, options?: { direction?: SortOrder; inPlace?: boolean; /** Controls chunk size for large array sorting. Arrays larger than chunkSize * will be sorted using a memory-efficient chunked algorithm. Default: 50000 */ chunkSize?: number; ignoreCase?: boolean; }): T[]; type SortOrder = 'asc' | 'desc'; export {};