Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

153
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda