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

151
Views
sort numeric value in table

I have implemented the below-sorting functionality to sort the column with numeric values, and it is working fine. I am looking way to extract a separate function so that I don't have to repeat the data index twice for each column in the column configuration array

const supplyAirHandlersTableColumns = [
    {
      title: <StrongTitleWithUnit title="Min Airflow"/>,
      dataIndex: ['supplyAirflow', 'minAirflow'],
      sorter: (a, b) => SORTABLE.NUMERIC(a, b, ['supplyAirflow', 'minAirflow']),
      render: Math.round
    },
    {
      title: <StrongTitleWithUnit title="Max Airflow"/>,
      dataIndex: ['supplyAirflow', 'maxAirflow'],
      sorter: (a, b) => SORTABLE.NUMERIC(a, b, ['supplyAirflow', 'maxAirflow']),
      render: Math.round
    }
]

And below is the function for SORTABLE.NUMERIC

export const SORTABLE = Object.freeze({
  NUMERIC: compareNumericProps
});

export const compareNumericProps = (a, b, prop) => get(a, prop) - get(b, prop);

Could anyone please let me know if I can extract this as a function to avoid repetitive data index, and I am using Antd UI library with react js?

Many thanks in advance!!!

I am looking like this kind of function sorter: sortNumericValue.

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!