UNPKG

@carbon/react

Version:

React components for the Carbon Design System

43 lines (42 loc) 1.49 kB
/** * Copyright IBM Corp. 2016, 2025 * * This source code is licensed under the Apache-2.0 license found in the * LICENSE file in the root directory of this source tree. */ import { type DataTableSortState } from '../state/sortStates'; /** * Compare two values to determine their order. If both values have the same * type, the default sort algorithm will be used for those types. Otherwise, the * values will be converted to strings for comparison. */ export declare const compare: (a: any, b: any, locale?: string) => number; interface Cell { id: string; value: any; } interface SortRowParams { key: string; sortDirection: DataTableSortState; sortStates: Record<DataTableSortState, DataTableSortState>; locale: string; compare: typeof compare; rowIds: string[]; } interface SortRowsConfig { rowIds: string[]; cellsById: Record<string, Cell>; key: string; sortDirection: DataTableSortState; locale?: string; sortRow?: (cellA: any, cellB: any, params: SortRowParams) => number; } /** * Sorts table rows based on the provided column key and direction. */ export declare const sortRows: ({ rowIds, cellsById, sortDirection, key, locale, sortRow, }: SortRowsConfig) => string[]; /** * Sorts table rows based on the sort direction. */ export declare const defaultSortRow: (cellA: any, cellB: any, { sortDirection, sortStates, locale, }: Pick<SortRowParams, "locale" | "sortDirection" | "sortStates">) => number; export {};