Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

165
Views
react-table custom sorting using sortType not working for boolean values

I have a list of column definitions, where I want to update one of them to allow for sorting in a particular way.

I can not get it to work. The propert plans in the data is a boolean. The column definition for "plans" looks like this after my code underneath has been run: accessor: "plans" canSort: true header: "plans" sequence: 0 sortType: ƒ boolSort(rowA, rowB, columnId) type: "string"

Here is my go at it


let newCols = columns;

    if (columns.length > 0) {
      const filteredCols = columns.filter(c => c.accessor !== "plans");

      const boolSort = (rowA, rowB, columnId) => {
        const a = rowA.values[columnId].toString();
        const b = rowB.values[columnId].toString();
        return a > b ? 1 : -1;
      };

      const change = columns.find(c => c.accessor === "plans");
      if (change) {
        change.canSort = true;
        change.sortType = boolSort;
        newCols = [...filteredCols, change];
      }

Why does the sorting not work for this column now?

"react-table": "^7.0.0-beta.15",
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!