Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

152
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda