1 if rowA > rowB, -1 if rowA < rowB, 0 if equal.
useReactTable({ sortingFns: { match: matchPercentageSortingFn }, ... });
// A row with matchPercentage 90 sorts after one with 70.
export function matchPercentageSortingFn(rowA: Row<Product>, rowB: Row<Product>) {
const a = rowA.original.matchPercentage ?? 0;
const b = rowB.original.matchPercentage ?? 0;
return a > b ? 1 : a < b ? -1 : 0;
}
Custom sorting function for match percentage comparison between two product rows. Compares the match percentage of products and returns a sort order value.