Skip to content

Commit

Permalink
✨ Add new argument for advanced use cases
Browse files Browse the repository at this point in the history
  • Loading branch information
dej611 authored Dec 7, 2023
1 parent 976e603 commit 861fde2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/components/datagrid/data_grid_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ export interface EuiDataGridSchemaDetector {
*/
detector: (value: string) => number;
/**
* A custom comparator function when performing in-memory sorting on this data type, takes `(a: string, b: string, direction: 'asc' | 'desc) => -1 | 0 | 1`
* A custom comparator function when performing in-memory sorting on this data type, takes `(a: string, b: string, direction: 'asc' | 'desc', indexes: {aIndex: number, bIndex: number}) => -1 | 0 | 1`
*/
comparator?: (a: string, b: string, direction: 'asc' | 'desc') => -1 | 0 | 1;
comparator?: (a: string, b: string, direction: 'asc' | 'desc', indexes: {aIndex: number, bIndex: number}) => -1 | 0 | 1;
/**
* The icon used to visually represent this data type. Accepts any `EuiIcon IconType`.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/components/datagrid/utils/sorting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export const useSorting = ({
}
}

const result = comparator(aValue, bValue, column.direction);
const result = comparator(aValue, bValue, column.direction, {aIndex: a.index, bIndex: b.index});
// only return if the columns are unequal, otherwise allow the next sort-by column to run
if (result !== 0) return result;
}
Expand Down

0 comments on commit 861fde2

Please sign in to comment.