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

92
Vistas
Sorting of Object inside Object On the basis of Order key

Sorting & arrange list of object inside object on the basis of order key

const listing = {
   "football":{
      "name":"FOOTBALL",
      "slug":"football",
      "arr":[],
      "order": 4
   },
   "table-tennis":{
      "name":"TABLE TENNIS",
      "slug":"table-tennis",
      "arr":[],
      "order": 1
   },
   "cricket":{
      "name":"CRICKET",
      "slug":"cricket",
      "arr":[],
      "order": 5
   },
   "badminton":{
      "name":"BADMINTON",
      "slug":"badminton",
      "arr":[],
      "order": 2
   },
   "hockey":{
      "name":"HOCKEY",
      "slug":"hockey",
      "arr":[],
      "order": 3
   }
}
Object.keys(listing).sort().map((item) => {
  return (
    <div>
      <div onClick={() => sportsKitFilter()}>{listing[item].name}</div>
    </div>
  )
})

Actual Result:-

BADMINTON
CRICKET
FOOTBALL
HOCKEY
TABLE TENNIS

Expected Result:-

TABLE TENNIS
BADMINTON
HOCKEY
FOOTBALL
CRICKET

So, In the expected result, Storing is on the basis of order key

Guide me, In this scenerio??

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Currently i am sorting listing.order. try this code it's working !

 Object.keys(listing).sort((a, b) => listing[a].order - listing[b].order).map((item) => {
      return (
        <div>
          <div onClick={() => sportsKitFilter()}>{listing[item].name}</div>
        </div>
      )
    })
about 4 years ago · Juan Pablo Isaza Denunciar

0

How's this for you?

const listing = {
  football: {
    name: "FOOTBALL",
    slug: "football",
    arr: [],
    order: 4,
  },
  "table-tennis": {
    name: "TABLE TENNIS",
    slug: "table-tennis",
    arr: [],
    order: 1,
  },
  cricket: {
    name: "CRICKET",
    slug: "cricket",
    arr: [],
    order: 5,
  },
  badminton: {
    name: "BADMINTON",
    slug: "badminton",
    arr: [],
    order: 2,
  },
  hockey: {
    name: "HOCKEY",
    slug: "hockey",
    arr: [],
    order: 3,
  },
};

const ordered = Object.keys(listing).sort(
  (a, b) => listing[a].order - listing[b].order
).map(item => ["YOUR JSX HERE"]);
about 4 years ago · Juan Pablo Isaza Denunciar
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