ChemPal Documentation - v0.0.13-beta.5
    Preparing search index...

    Function matchPercentageSortingFn

    • Custom sorting function for match percentage comparison between two product rows. Compares the match percentage of products and returns a sort order value.

      Parameters

      • rowA: Row<Product>

        The first row to compare.

      • rowB: Row<Product>

        The second row to compare.

      Returns -1 | 0 | 1

      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;
      }