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

134
Views
Ordenar desc si el elemento está incluido en una matriz con lodash o sin

Tengo una serie de objetos como este:

 const attendList = [ { "first": "John", "last": "Foo", "uid": "-Lz8YxIYM_4L3f9nKM70", }, { "first": "Jake", "last": "Foo", "uid": "-Lz8YxIYM_4L3fsdfM70", } ... ]

Entonces tengo una matriz que contiene las claves.

 const found = ["-Lz8YxIYM_4L3fsdfM70", "-Lz8YxIYM_4L3fsdf333", "-Lz8YxIYM_r4hfsdf333" ]

Quiero ordenar la lista de asistencia colocando los elementos que se encuentran al final de la lista. Mi intento incorrecto (usando lodash) es:

 let SetItemsLast = _.sortBy(attendList, ({uid}) => found.includes(uid) ? 0:1);

Obviamente no lo estoy haciendo correctamente. ¿Cómo puedo resolver esto?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Intente esto si necesita mantener los elementos de la lista de asistencia en orden.

 let SetItemsLast = attendList.sort((a, b)=>{ if(found.includes(a.uid)){ return 1; } if(found.includes(b.uid)){ return -1; } return 0; });

Si no le importa si los elementos en la parte inferior permanecen en orden, puede hacer esto.

 let SetItemsLast = attendList.sort((a, b)=>{ return found.includes(b.uid) ? -1:0; });
about 4 years ago · Juan Pablo Isaza Report
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!